diff --git a/cjs/groupChannel.js b/cjs/groupChannel.js new file mode 100644 index 0000000..2afe3af --- /dev/null +++ b/cjs/groupChannel.js @@ -0,0 +1 @@ +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t,s,n,i,a,r,o,l,d=require("./lib/__bundle-032c97c6.js"),h=require("./lib/__bundle-aa0921e3.js"),u=require("./lib/__bundle-c8f25be2.js"),c=require("./lib/__bundle-aba6d9af.js"),_=require("./lib/__bundle-7e34e7ed.js"),p=require("./lib/__bundle-481ecf03.js");exports.MemberState=void 0,(e=exports.MemberState||(exports.MemberState={})).NONE="none",e.JOINED="joined",e.INVITED="invited",e.LEFT="left";class m extends h.RestrictedUser{constructor(e,t){super(e,t),this.state=null,this.role=null,this.isMuted=!1,this.isBlockedByMe=!1,this.isBlockingMe=!1,this.state=d.isEnumOf(exports.MemberState,t.state)?t.state:null,this.role=d.isEnumOf(d.Role,t.role)?t.role:null,"boolean"==typeof t.is_muted&&(this.isMuted=t.is_muted),"boolean"==typeof t.is_blocked_by_me&&(this.isBlockedByMe=t.is_blocked_by_me),"boolean"==typeof t.is_blocking_me&&(this.isBlockingMe=t.is_blocking_me)}static payloadify(e){return d.deundefined(d.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{state:e.state,role:e.role,is_muted:e.isMuted,is_blocked_by_me:e.isBlockedByMe,is_blocking_me:e.isBlockingMe})))}}class g extends d.InstancedObject{constructor(e,t){var s,n;super(e),this.channelUrl=null!==(s=t.channel_url)&&void 0!==s?s:"",this.channelType=null!==(n=t.channel_type)&&void 0!==n?n:d.ChannelType.GROUP,this.reader=new d.User(this._iid,t.user),this.readAt=t.ts}}exports.PublicChannelFilter=void 0,(t=exports.PublicChannelFilter||(exports.PublicChannelFilter={})).ALL="all",t.PUBLIC="public",t.PRIVATE="private",exports.MyMemberStateFilter=void 0,(s=exports.MyMemberStateFilter||(exports.MyMemberStateFilter={})).ALL="all",s.JOINED="joined_only",s.INVITED="invited_only",s.INVITED_BY_FRIEND="invited_by_friend",s.INVITED_BY_NON_FRIEND="invited_by_non_friend",exports.SuperChannelFilter=void 0,(n=exports.SuperChannelFilter||(exports.SuperChannelFilter={})).ALL="all",n.SUPER="super",n.NON_SUPER="nonsuper",n.BROADCAST_ONLY="broadcast_only",n.EXCLUSIVE_ONLY="exclusive_only",exports.UnreadChannelFilter=void 0,(i=exports.UnreadChannelFilter||(exports.UnreadChannelFilter={})).ALL="all",i.UNREAD_MESSAGE="unread_message",exports.HiddenChannelFilter=void 0,(a=exports.HiddenChannelFilter||(exports.HiddenChannelFilter={})).ALL="all",a.UNHIDDEN="unhidden_only",a.HIDDEN="hidden_only",a.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",a.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide",exports.OperatorFilter=void 0,(r=exports.OperatorFilter||(exports.OperatorFilter={})).ALL="all",r.OPERATOR="operator",r.NONOPERATOR="nonoperator",exports.QueryType=void 0,(o=exports.QueryType||(exports.QueryType={})).AND="AND",o.OR="OR",exports.GroupChannelSearchField=void 0,(l=exports.GroupChannelSearchField||(exports.GroupChannelSearchField={})).MEMBER_NICKNAME="member_nickname",l.CHANNEL_NAME="channel_name";class C{constructor(){this._searchFilter=null,this._userIdsFilter=null,this.includeEmpty=!1,this.nicknameContainsFilter=null,this.nicknameStartsWithFilter=null,this.nicknameExactMatchFilter=null,this.channelNameContainsFilter="",this.myMemberStateFilter=exports.MyMemberStateFilter.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=exports.SuperChannelFilter.ALL,this.publicChannelFilter=exports.PublicChannelFilter.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=exports.UnreadChannelFilter.ALL,this.hiddenChannelFilter=exports.HiddenChannelFilter.UNHIDDEN,this.includeFrozen=!0}_isFriend(e){return!(!e||!e.friendDiscoveryKey&&!e.friendName)}get searchFilter(){return this._searchFilter}setSearchFilter(e,t){Array.isArray(e)&&0!==e.length&&"string"==typeof t&&t&&(this._searchFilter={query:t,fields:e})}get userIdsFilter(){return this._userIdsFilter}setUserIdsFilter(e,t,s=exports.QueryType.AND){this._userIdsFilter={userIds:e,includeMode:t,queryType:s}}clone(){var e;const t=new C;this.searchFilter&&t.setSearchFilter(this.searchFilter.fields,null!==(e=this.searchFilter.query)&&void 0!==e?e:void 0),this.userIdsFilter&&t.setUserIdsFilter(this.userIdsFilter.userIds,this.userIdsFilter.includeMode,this.userIdsFilter.queryType);const s=JSON.parse(JSON.stringify(this));return Object.keys(s).forEach((e=>{t[e]=s[e]})),t}match(e,t){if(this._searchFilter){const{query:t,fields:s}=this._searchFilter;if(t&&s&&s.length>0&&!s.some((s=>{switch(s){case exports.GroupChannelSearchField.CHANNEL_NAME:return e.name.toLowerCase().includes(t.toLowerCase());case exports.GroupChannelSearchField.MEMBER_NICKNAME:return e.members.some((e=>e.nickname.toLowerCase().includes(t.toLowerCase())));default:return!0}})))return!1}if(this._userIdsFilter){const{userIds:s,includeMode:n,queryType:i}=this._userIdsFilter,a=e.members.map((e=>e.userId));if(n){if(s.length>0)switch(i){case exports.QueryType.AND:if(s.some((e=>!a.includes(e))))return!1;break;case exports.QueryType.OR:if(s.every((e=>!a.includes(e))))return!1}}else{if(s.includes(t)||s.push(t),e.members.length>s.length)return!1;if(!d.hasSameMembers(s,a))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(`^${this.customTypeStartsWithFilter}`).test(e.customType))return!1;if(this.channelNameContainsFilter&&!e.name.toLowerCase().includes(this.channelNameContainsFilter.toLowerCase()))return!1;if(this.nicknameContainsFilter){const s=this.nicknameContainsFilter.toLowerCase();if(!e.members.some((e=>e.userId!==t&&e.nickname.toLowerCase().includes(s))))return!1}if(this.nicknameStartsWithFilter){const s=this.nicknameStartsWithFilter.toLowerCase();if(!e.members.some((e=>e.userId!==t&&e.nickname.toLowerCase().startsWith(s))))return!1}if(this.nicknameExactMatchFilter){const s=this.nicknameExactMatchFilter.toLowerCase();if(!e.members.some((e=>e.userId!==t&&e.nickname.toLowerCase()!=s)))return!1}if(this.channelUrlsFilter&&this.channelUrlsFilter.length>0&&!this.channelUrlsFilter.includes(e.url))return!1;if(this.myMemberStateFilter)switch(this.myMemberStateFilter){case exports.MyMemberStateFilter.JOINED:if("joined"!==e.myMemberState)return!1;break;case exports.MyMemberStateFilter.INVITED:if("invited"!==e.myMemberState)return!1;break;case exports.MyMemberStateFilter.INVITED_BY_FRIEND:if("invited"!==e.myMemberState||!this._isFriend(e.inviter))return!1;break;case exports.MyMemberStateFilter.INVITED_BY_NON_FRIEND:if("invited"!==e.myMemberState||this._isFriend(e.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case exports.HiddenChannelFilter.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case exports.HiddenChannelFilter.HIDDEN:if(!e.isHidden)return!1;break;case exports.HiddenChannelFilter.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case exports.HiddenChannelFilter.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===exports.UnreadChannelFilter.UNREAD_MESSAGE)if(0===e.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case exports.PublicChannelFilter.PUBLIC:if(!e.isPublic)return!1;break;case exports.PublicChannelFilter.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case exports.SuperChannelFilter.SUPER:if(!e.isSuper)return!1;break;case exports.SuperChannelFilter.NON_SUPER:if(e.isSuper)return!1}return!0}}class v extends d.InstancedObject{constructor(e,{sdkState:t,cacheContext:s}){super(e),this._channels=new Map,this._sdkState=t,this._cacheContext=s}get collection(){const{nestdb:e}=this._cacheContext;return d.unless(!!e).throw(d.SendbirdError.databaseError),e.collection(h.NESTDB_GROUPCHANNEL_COLLECTION_NAME)}get localCacheEnabled(){const{localCacheEnabled:e}=this._cacheContext;return e&&!!this.collection}_serialize(e,t=0){return Object.assign(Object.assign({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})}_deserialize(e){return Ae.of(this._iid).buildGroupChannelFromSerializedData(e)}get channels(){return[...this._channels.values()]}isCachedInMemory(e){return this._channels.has(e)}filterOffsetChanged(e){return e.filter((e=>{if(this._channels.has(e.url)){return this._channels.get(e.url).messageOffsetTimestamp{if(e)switch(i){case u.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:if(!s&&t.name.localeCompare(e)<0||s&&t.name.localeCompare(e)>0)return!1;if(a&&a===t.url)return!1;break;case u.GroupChannelListOrder.CHRONOLOGICAL:if(!s&&t.createdAt>e||s&&t.createdAte||s&&t.lastMessageUpdatedAtthis._deserialize(e)));return l.forEach((e=>{this._channels.has(e.url)||this._channels.set(e.url,e)})),l}return[]}))}upsert(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=[];if(e.forEach((e=>{if(this._channels.has(e.url)){const s=this._channels.get(e.url);s._pinnedMessagesUpdatedAt0&&(yield this.upsert(n))}))}block(e,t){return d.__awaiter(this,void 0,void 0,(function*(){yield this._setBlockStateOfAllChannels(e,t,!0)}))}unblock(e,t){return d.__awaiter(this,void 0,void 0,(function*(){yield this._setBlockStateOfAllChannels(e,t,!1)}))}markAsRead(e,t=[...this._channels.keys()]){return d.__awaiter(this,void 0,void 0,(function*(){const s=[];for(const n of t){const t=yield this.get(n);(null==t?void 0:t._updateUnreadMemberState(this._sdkState.userId,e))&&(t._updateUnreadCount(0,0),s.push(t))}s.length>0&&(yield this.upsert(s))}))}}const E={invitedUserIds:void 0,channelUrl:void 0,coverUrl:void 0,coverImage:void 0,isDistinct:void 0,isSuper:void 0,isBroadcast:void 0,isExclusive:void 0,isPublic:void 0,isDiscoverable:void 0,isStrict:void 0,isEphemeral:void 0,accessCode:void 0,name:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,messageSurvivalSeconds:void 0},f=e=>d.isArrayOf("string",e.invitedUserIds,!0)&&d.isTypeOf("string",e.channelUrl,!0)&&d.isTypeOf("string",e.coverUrl,!0)&&(d.isFile(e.coverImage)||d.isTypeOf("string",e.coverImage,!0))&&d.isTypeOf("boolean",e.isDistinct,!0)&&d.isTypeOf("boolean",e.isSuper,!0)&&d.isTypeOf("boolean",e.isBroadcast,!0)&&d.isTypeOf("boolean",e.isExclusive,!0)&&d.isTypeOf("boolean",e.isPublic,!0)&&d.isTypeOf("boolean",e.isStrict,!0)&&d.isTypeOf("boolean",e.isDiscoverable,!0)&&d.isTypeOf("boolean",e.isEphemeral,!0)&&d.isTypeOf("string",e.accessCode,!0)&&d.isTypeOf("string",e.name,!0)&&d.isTypeOf("string",e.data,!0)&&d.isTypeOf("string",e.customType,!0)&&d.isArrayOf("string",e.operatorUserIds,!0)&&d.isTypeOf("number",e.messageSurvivalSeconds,!0),M={customTypes:void 0,includeEmpty:!1,includeFrozen:!0},y=e=>d.isArrayOf("string",e.customTypes,!0)&&d.isTypeOf("boolean",e.includeEmpty)&&d.isTypeOf("boolean",e.includeFrozen),S={myMemberStateFilter:exports.MyMemberStateFilter.ALL},b=e=>d.isEnumOf(exports.MyMemberStateFilter,e.myMemberStateFilter);var A;exports.UnreadItemKey=void 0,(A=exports.UnreadItemKey||(exports.UnreadItemKey={})).GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",A.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",A.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",A.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",A.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",A.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",A.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",A.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",A.SUPER_INVITATION_COUNT="super_group_channel_invitation_count";const U={keys:[]},T={channelCustomTypesFilter:void 0,superChannelFilter:exports.SuperChannelFilter.ALL},N={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:d.MessageTypeFilter.ALL};class I{constructor({groupChannelCache:e,messageCache:t,unsentMessageCache:s,dispatcher:n}){this._observers=new Map,n.on((n=>d.__awaiter(this,void 0,void 0,(function*(){if(n instanceof u.GroupChannelUpdateEventCommand){const{channels:s,source:i,isWebSocketEventComing:a,data:r}=n,o=s.filter((e=>e instanceof Ot)),l=e.filterOffsetChanged(o);for(const e of l)yield t.removeUnderOffset(e.url,e.messageOffsetTimestamp);const d=yield e.upsert(o);a||this._broadcastUpdateEvent(d,i,r)}else if(n instanceof u.GroupChannelRemoveEventCommand){const{channelUrls:i,source:a,isWebSocketEventComing:r}=n;yield e.remove(i),yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of i)yield t.removeMessagesOfChannel(e),yield s.removeMessagesOfChannel(e)})))),r||this._broadcastRemoveEvent(i,a)}else n instanceof u.DatabaseOpenCommand&&(yield e.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER}))}))))}_broadcastUpdateEvent(e,t,s){for(const n of this._observers.values())n.onUpdate&&n.onUpdate(e,t,s)}_broadcastRemoveEvent(e,t){for(const s of this._observers.values())s.onRemove&&s.onRemove(e,t)}subscribe(e,t){this._observers.set(e,t)}unsubscribe(e){this._observers.delete(e)}unsubscribeAll(){this._observers.clear()}}class O{constructor({cacheContext:e,messageCache:t,unsentMessageCache:s,dispatcher:n,logger:i}){this._observers=new Map,this._cacheContext=e,this._logger=i,n.on((e=>d.__awaiter(this,void 0,void 0,(function*(){if(e instanceof d.MessageUpdateEventCommand){const{messages:n,source:i,isWebSocketEventComing:a}=e,r=n.filter((e=>e.messageId>0)),o=n.filter((e=>0===e.messageId));r.length>0&&(yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){yield t.upsert(r),yield s.remove(r.map((e=>e instanceof _.SendableMessage?e.reqId:null)).filter((e=>null!==e)))})))),a||this._broadcastUpdateEvent(r,i)),o.length>0&&(yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){yield s.upsert(o)})))),a||this._broadcastUpdateEvent(o,i))}else if(e instanceof d.MessageRemoveEventCommand){const{messageIds:s,source:n,isWebSocketEventComing:i}=e;yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){yield t.remove(s)})))),i||this._broadcastRemoveEvent(s,n)}else if(e instanceof d.UnsentMessageRemoveEventCommand){const{reqId:t,source:n}=e;yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){yield s.remove([t])})))),this._broadcastRemoveUnsentEvent(t,n)}else if(e instanceof d.PollChangeLogEventCommand){const{polls:s,source:n}=e;if(this._cacheContext.localCacheEnabled){const e=s.map((e=>e.messageId)),n=(yield Promise.all(e.map((e=>t.get(e))))).filter((e=>e));n.length>0&&s.forEach((e=>{const t=n.find((t=>t.messageId===e.messageId));t&&t.applyPoll(e)})),yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){return yield t.upsert(n)}))))}this._broadcastPollChangeLogEvent(s,n)}else if(e instanceof d.PollUpdateInternalEventCommand){const{event:s,source:n}=e,i=yield t.get(s.messageId);i&&i.isUserMessage()&&i.poll&&i.poll.applyPollUpdateEvent(s)&&(yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){return yield t.upsert([i])}))))),this._broadcastPollUpdateEvent(s,n)}else if(e instanceof d.PollVoteInternalEventCommand){const{event:s,source:n}=e,i=yield t.get(s.messageId);i&&i.isUserMessage()&&i.poll&&i.poll.applyPollVoteEvent(s)&&(yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){return yield t.upsert([i])}))))),this._broadcastPollVoteEvent(s,n)}}))))}_broadcastUpdateEvent(e,t){for(const s of this._observers.values())s.onUpdate&&s.onUpdate(e,t)}_broadcastPollChangeLogEvent(e,t){for(const s of this._observers.values())s.onPollChangeLogUpdate&&s.onPollChangeLogUpdate(e,t)}_broadcastPollUpdateEvent(e,t){for(const s of this._observers.values())s.onPollUpdate&&s.onPollUpdate(e,t)}_broadcastPollVoteEvent(e,t){for(const s of this._observers.values())s.onPollVote&&s.onPollVote(e,t)}_broadcastRemoveEvent(e,t){for(const s of this._observers.values())s.onRemove&&s.onRemove(e,t)}_broadcastRemoveUnsentEvent(e,t){for(const s of this._observers.values())s.onRemoveUnsent&&s.onRemoveUnsent(e,t)}subscribe(e,t){this._observers.set(e,t)}unsubscribe(e){this._observers.delete(e)}unsubscribeAll(){this._observers.clear()}}class P extends d.APIRequestCommand{constructor({userId:e,ts:t,token:s,filter:n}){super();const{customTypes:i,includeEmpty:a,includeFrozen:r}=Object.assign(Object.assign({},M),n);this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/my_group_channels/changelogs`,this.params=d.deundefined(d.undefineNullProps({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:t||null,token:s,custom_types:i,show_empty:a,show_frozen:r}))}}class w extends d.APIResponseCommand{constructor(e,t){super(e,t),this.updatedChannels=t.updated.map((t=>new Ot(e,t))),this.deletedChannelUrls=t.deleted,this.hasMore=t.has_more,this.token=t.next}}class x extends d.APIRequestCommand{constructor({channelUrl:e,isInternalCall:t}){super(),this.method=d.APIRequestMethod.GET,this.path=`${t?d.API_PATH_GROUP_CHANNELS_INTERNAL:d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(e)}`,this.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0}}}class R extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new Ot(e,t)}}const L={includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,channelUrlsFilter:void 0,customTypesFilter:void 0,customTypeStartsWithFilter:void 0,nicknameContainsFilter:void 0,nicknameStartsWithFilter:void 0,nicknameExactMatchFilter:void 0,channelNameContainsFilter:void 0,myMemberStateFilter:exports.MyMemberStateFilter.ALL,unreadChannelFilter:exports.UnreadChannelFilter.ALL,superChannelFilter:exports.SuperChannelFilter.ALL,publicChannelFilter:exports.PublicChannelFilter.ALL,hiddenChannelFilter:exports.HiddenChannelFilter.ALL,userIdsFilter:{userIds:[],includeMode:!0,queryType:exports.QueryType.AND},searchFilter:{query:void 0,fields:[]},metadataKey:void 0,metadataValues:void 0,metadataOrderKeyFilter:void 0,metadataValueStartsWith:void 0,order:u.GroupChannelListOrder.LATEST_LAST_MESSAGE};class F extends d.APIRequestCommand{constructor(e){const{userId:t,token:s,limit:n,order:i,includeEmpty:a,myMemberStateFilter:r,superChannelFilter:o,publicChannelFilter:l,unreadChannelFilter:h,nicknameContainsFilter:u,nicknameStartsWithFilter:c,nicknameExactMatchFilter:_,channelNameContainsFilter:p,channelUrlsFilter:m,customTypesFilter:g,customTypeStartsWithFilter:C,hiddenChannelFilter:v,metadataOrderKeyFilter:E,metadataKey:f,metadataValues:M,metadataValueStartsWith:y,includeFrozen:S,includeMetaData:b,searchFilter:A,userIdsFilter:U}=e;super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(t)}/my_group_channels`,this.params=d.deundefined({token:s,limit:n,order:null!=i?i:L.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=a?a:L.includeEmpty,member_state_filter:null!=r?r:L.myMemberStateFilter,super_mode:null!=o?o:L.superChannelFilter,public_mode:null!=l?l:L.publicChannelFilter,unread_filter:null!=h?h:L.unreadChannelFilter,members_nickname_contains:u,members_nickname_startswith:c,members_nickname:_,name_contains:p,channel_urls:m,custom_types:g,custom_type_startswith:C,hidden_mode:v,metadata_order_key:E,metadata_key:f,metadata_values:M,metadata_value_startswith:y,show_frozen:S,show_metadata:b}),A&&A.query&&A.fields&&(this.params.search_query=A.query,this.params.search_fields=A.fields),U&&U.userIds&&U.userIds.length>0&&(U.includeMode?(this.params.members_include_in=U.userIds,this.params.query_type=U.queryType.toUpperCase()):this.params.members_exactly_in=U.userIds)}}class k extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channels=[];const{next:s,channels:n,ts:i}=t;this.token=s,n&&n.length>0&&(this.channels=n.map((t=>(t.ts=i,new Ot(e,t))))),this.ts=null!=i?i:0}}class D extends d.APIRequestCommand{constructor({userId:e,filter:t}){super();const{myMemberStateFilter:s}=t;this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/group_channel_count`,this.params={state:null!=s?s:exports.MyMemberStateFilter.ALL}}}class G extends d.APIResponseCommand{constructor(e,t){super(e,t),this.groupChannelCount=t.group_channel_count}}class H extends d.APIRequestCommand{constructor({userId:e,filter:t}){super();const{keys:s}=t;this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_item_count`,this.params=d.deundefined({item_keys:s})}}class V extends d.APIResponseCommand{constructor(e,t){super(e,t),"number"==typeof t[exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]&&(this.groupChannelUnreadMentionCount=t[exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MENTION_COUNT]),"number"==typeof t[exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]&&(this.groupChannelUnreadMessageCount=t[exports.UnreadItemKey.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT]),"number"==typeof t[exports.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]&&(this.groupChannelInvitationCount=t[exports.UnreadItemKey.GROUP_CHANNEL_INVITATION_COUNT]),"number"==typeof t[exports.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]&&(this.superGroupChannelUnreadMentionCount=t[exports.UnreadItemKey.SUPER_UNREAD_MENTION_COUNT]),"number"==typeof t[exports.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]&&(this.superGroupChannelUnreadMessageCount=t[exports.UnreadItemKey.SUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof t[exports.UnreadItemKey.SUPER_INVITATION_COUNT]&&(this.superGroupChannelInvitationCount=t[exports.UnreadItemKey.SUPER_INVITATION_COUNT]),"number"==typeof t[exports.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]&&(this.nonSuperGroupChannelUnreadMentionCount=t[exports.UnreadItemKey.NONSUPER_UNREAD_MENTION_COUNT]),"number"==typeof t[exports.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]&&(this.nonSuperGroupChannelUnreadMessageCount=t[exports.UnreadItemKey.NONSUPER_UNREAD_MESSAGE_COUNT]),"number"==typeof t[exports.UnreadItemKey.NONSUPER_INVITATION_COUNT]&&(this.nonSuperGroupChannelInvitationCount=t[exports.UnreadItemKey.NONSUPER_INVITATION_COUNT])}}class q extends d.APIRequestCommand{constructor({userId:e}){super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_channel_count`}}class j extends d.APIResponseCommand{constructor(e,t){super(e,t),this.unreadCount=t.unread_count}}class B extends d.APIRequestCommand{constructor({userId:e,filter:t}){super();const{channelCustomTypesFilter:s,superChannelFilter:n}=t;this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/unread_message_count`,this.params={super_mode:null!=n?n:exports.SuperChannelFilter.ALL,custom_types:s}}}class W extends d.APIResponseCommand{constructor(e,t){super(e,t),this.unreadCount=t.unread_count}}class $ extends d.APIRequestCommand{constructor({channelUrl:e,scheduledStatus:t,messageTypeFilter:s}){super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_SCHEDULED_MESSAGES}/count`,this.params={channel_url:e,status:Q(t)},s&&(this.params.message_type=s)}}class z extends d.APIResponseCommand{constructor(e,t){super(e,t),this.count=t.count}}const Q=e=>{if(!e)return[];const t=[];return e.forEach((e=>{switch(e){case _.ScheduledStatus.PENDING:t.push(_.InternalScheduledStatus.PENDING);break;case _.ScheduledStatus.SENT:t.push(_.InternalScheduledStatus.IN_QUEUE),t.push(_.InternalScheduledStatus.SENT);break;case _.ScheduledStatus.CANCELED:t.push(_.InternalScheduledStatus.CANCELED);break;case _.ScheduledStatus.FAILED:t.push(_.InternalScheduledStatus.FAILED)}})),t};class K extends d.APIRequestCommand{constructor(e){const{userId:t,channelUrl:s,coverUrl:n,coverImage:i,isDistinct:a,isSuper:r,isBroadcast:o,isPublic:l,isExclusive:h,isDiscoverable:u,isStrict:c,isEphemeral:_,accessCode:p,name:m,data:g,customType:C,messageSurvivalSeconds:v,invitedUserIds:E,operatorUserIds:f}=e;super(),this.method=d.APIRequestMethod.POST,this.path=d.API_PATH_GROUP_CHANNELS,this.params=d.deundefined({user_ids:[t,...null!=E?E:[]].filter(((e,t,s)=>t===s.indexOf(e))),channel_url:s,cover_url:n,cover_file:i,is_distinct:a,is_super:r,is_broadcast:o,is_exclusive:h,is_public:l,is_discoverable:u,strict:c,is_ephemeral:_,access_code:p,name:m,data:g,custom_type:C,operator_ids:f,message_survival_seconds:v})}}class Y extends d.APIResponseCommand{constructor(e,t){var s;super(e,t),this.channel=new Ot(e,t),this.isCreated=null===(s=t.is_created)||void 0===s||s}}class J extends d.APIRequestCommand{constructor({userId:e,channelUrls:t}){super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/mark_as_read_all`,this.params={channel_urls:t}}}class X extends d.APIRequestCommand{constructor(e){const{channelUrl:t,userId:s,accessCode:n}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/join`,this.params={user_id:s,access_code:n}}}class Z extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new Ot(e,t)}}class ee extends c.ChannelEventCommand{constructor(e,t,s){super(e,t,s);const{member_count:n=0,joined_member_count:i=0,users:a=null}=s.data;this.memberCount=n,this.joinedMemberCount=i,this.members=Array.isArray(a)?a.map((t=>new m(e,t))):[new m(e,s.data)]}}class te extends d.APIRequestCommand{constructor(e){const{channelUrl:t,userId:s,shouldRemoveOperatorStatus:n}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/leave`,this.params={user_id:s,should_remove_operator_status:n}}}class se extends c.ChannelEventCommand{constructor(e,t,s){super(e,t,s);const{member_count:n=0,joined_member_count:i=0}=s.data;this.memberCount=n,this.joinedMemberCount=i,this.member=new m(this._iid,s.data)}}class ne extends d.APIRequestCommand{constructor(e){const{channelUrl:t,userIds:s}=e;super(),this.method=d.APIRequestMethod.POST,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/invite`,this.params={user_ids:s}}}class ie extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new Ot(e,t)}}class ae extends c.ChannelEventCommand{constructor(e,t,s){super(e,t,s);const{member_count:n=0,joined_member_count:i=0,inviter:a,invitees:r=[]}=s.data;this.memberCount=n,this.joinedMemberCount=i,this.inviter=new d.User(e,a),this.invitees=r.map((t=>new m(e,t)))}}class re extends d.APIRequestCommand{constructor(e){const{channelUrl:t,userId:s}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/decline`,this.params={user_id:s}}}class oe extends c.ChannelEventCommand{constructor(e,t,s){super(e,t,s);const{member_count:n,joined_member_count:i,inviter:a,invitee:r}=s.data;this.memberCount=null!=n?n:0,this.joinedMemberCount=null!=i?i:0,this.inviter=new d.User(e,a),this.invitee=new m(e,r)}}class le extends d.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"READ",ackRequired:!0,payload:{channel_url:e}})}}class de extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"READ",s),this.readStatus=new g(e,s)}}class he extends d.APIRequestCommand{constructor({channelUrl:e,userId:t}){super(),super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(e)}/messages/mark_as_delivered`,this.params=d.deundefined({userId:t})}}class ue extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"DLVR",s),this.channelUrl=s.channel_url,this.deliveredStateUpdate=s.updated}}const ce={hidePreviousMessages:!1,allowAutoUnhide:!0};class _e extends d.APIRequestCommand{constructor(e){const{channelUrl:t,userId:s,hidePreviousMessages:n,allowAutoUnhide:i}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/hide`,this.params={user_id:s,hide_previous_messages:null!=n?n:ce.hidePreviousMessages,allow_auto_unhide:null!=i?i:ce.allowAutoUnhide}}}class pe extends d.APIResponseCommand{constructor(e,t){super(e,t);const{ts_message_offset:s}=t;this.messageOffsetTimestamp=s}}class me extends d.WebSocketEventCommand{constructor(e,t,s){var n,i,a;super(e,"SYEV",s),this.allowAutoUnhide=null,this.hidePreviousMessages=null,this.messageOffsetTimestamp=null,s.data&&(this.allowAutoUnhide=null!==(n=s.data.allow_auto_unhide)&&void 0!==n?n:null,this.hidePreviousMessages=null!==(i=s.data.hide_previous_messages)&&void 0!==i?i:null),this.messageOffsetTimestamp=null!==(a=s.ts_message_offset)&&void 0!==a?a:null}}class ge extends d.WebSocketRequestCommand{constructor({channelUrl:e,time:t}){super({code:"TPST",ackRequired:!1,payload:{channel_url:e,time:t}})}}class Ce extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new d.User(e,s.data)}}class ve extends d.WebSocketRequestCommand{constructor({channelUrl:e,time:t}){super({code:"TPEN",ackRequired:!1,payload:{channel_url:e,time:t}})}}class Ee extends d.WebSocketEventCommand{constructor(e,t,s){super(e,"SYEV",s),this.user=new d.User(e,s.data)}}class fe extends d.WebSocketRequestCommand{constructor({channelUrl:e,messageId:t}){super({code:"MACK",ackRequired:!1,payload:{channel_url:e,msg_id:t}})}}class Me extends d.BaseListQuery{constructor(e,t){var s,n,i,a,r,o,l,d,h,c,_,p,m,g,C,v,E,f,M,y,S,b;super(e,t),this.includeEmpty=!1,this.includeFrozen=!0,this.includeMetaData=!0,this.channelUrlsFilter=null,this.customTypesFilter=null,this.customTypeStartsWithFilter=null,this.nicknameContainsFilter=null,this.nicknameStartsWithFilter=null,this.nicknameExactMatchFilter=null,this.channelNameContainsFilter="",this.myMemberStateFilter=exports.MyMemberStateFilter.ALL,this.unreadChannelFilter=exports.UnreadChannelFilter.ALL,this.superChannelFilter=exports.SuperChannelFilter.ALL,this.publicChannelFilter=exports.PublicChannelFilter.ALL,this.hiddenChannelFilter=exports.HiddenChannelFilter.UNHIDDEN,this.searchFilter={fields:[],query:null},this.userIdsFilter={userIds:[],includeMode:!0,queryType:exports.QueryType.AND},this.metadataKey=null,this.metadataValues=null,this.metadataOrderKeyFilter=null,this.metadataValueStartsWith=null,this.order=u.GroupChannelListOrder.LATEST_LAST_MESSAGE,this.includeEmpty=null!==(s=t.includeEmpty)&&void 0!==s&&s,this.includeFrozen=null===(n=t.includeFrozen)||void 0===n||n,this.includeMetaData=null===(i=t.includeMetaData)||void 0===i||i,this.channelUrlsFilter=null!==(a=t.channelUrlsFilter)&&void 0!==a?a:null,this.customTypesFilter=null!==(r=t.customTypesFilter)&&void 0!==r?r:null,this.customTypeStartsWithFilter=null!==(o=t.customTypeStartsWithFilter)&&void 0!==o?o:"",this.nicknameContainsFilter=null!==(l=t.nicknameContainsFilter)&&void 0!==l?l:null,this.nicknameStartsWithFilter=null!==(d=t.nicknameStartsWithFilter)&&void 0!==d?d:null,this.nicknameExactMatchFilter=null!==(h=t.nicknameExactMatchFilter)&&void 0!==h?h:null,this.channelNameContainsFilter=null!==(c=t.channelNameContainsFilter)&&void 0!==c?c:"",this.myMemberStateFilter=null!==(_=t.myMemberStateFilter)&&void 0!==_?_:exports.MyMemberStateFilter.ALL,this.unreadChannelFilter=null!==(p=t.unreadChannelFilter)&&void 0!==p?p:exports.UnreadChannelFilter.ALL,this.superChannelFilter=null!==(m=t.superChannelFilter)&&void 0!==m?m:exports.SuperChannelFilter.ALL,this.publicChannelFilter=null!==(g=t.publicChannelFilter)&&void 0!==g?g:exports.PublicChannelFilter.ALL,this.hiddenChannelFilter=null!==(C=t.hiddenChannelFilter)&&void 0!==C?C:exports.HiddenChannelFilter.UNHIDDEN,this.searchFilter=null!==(v=t.searchFilter)&&void 0!==v?v:{fields:[],query:null},this.userIdsFilter=null!==(E=t.userIdsFilter)&&void 0!==E?E:{userIds:[],includeMode:!0,queryType:exports.QueryType.AND},this.metadataKey=null!==(f=t.metadataKey)&&void 0!==f?f:null,this.metadataValues=null!==(M=t.metadataValues)&&void 0!==M?M:null,this.metadataOrderKeyFilter=null!==(y=t.metadataOrderKeyFilter)&&void 0!==y?y:null,this.metadataValueStartsWith=null!==(S=t.metadataValueStartsWith)&&void 0!==S?S:null,this.order=null!==(b=t.order)&&void 0!==b?b:u.GroupChannelListOrder.LATEST_LAST_MESSAGE}_validate(){return super._validate()&&d.isTypeOf("boolean",this.includeEmpty)&&d.isTypeOf("boolean",this.includeFrozen)&&d.isTypeOf("boolean",this.includeMetaData)&&d.isTypeOf("string",this.channelNameContainsFilter)&&d.isArrayOf("string",this.channelUrlsFilter,!0)&&d.isArrayOf("string",this.customTypesFilter,!0)&&d.isTypeOf("string",this.customTypeStartsWithFilter)&&d.isTypeOf("string",this.nicknameContainsFilter,!0)&&d.isTypeOf("string",this.nicknameStartsWithFilter,!0)&&d.isTypeOf("string",this.nicknameExactMatchFilter,!0)&&d.isEnumOf(exports.MyMemberStateFilter,this.myMemberStateFilter)&&d.isEnumOf(exports.SuperChannelFilter,this.superChannelFilter)&&d.isEnumOf(exports.PublicChannelFilter,this.publicChannelFilter)&&d.isEnumOf(exports.UnreadChannelFilter,this.unreadChannelFilter)&&d.isEnumOf(exports.HiddenChannelFilter,this.hiddenChannelFilter)&&d.isArrayOf(exports.GroupChannelSearchField,this.searchFilter.fields)&&d.isTypeOf("string",this.searchFilter.query,!0)&&d.isArrayOf("string",this.userIdsFilter.userIds)&&d.isTypeOf("boolean",this.userIdsFilter.includeMode)&&d.isEnumOf(exports.QueryType,this.userIdsFilter.queryType)&&d.isEnumOf(u.GroupChannelListOrder,this.order)&&d.isTypeOf("string",this.metadataOrderKeyFilter,!0)&&d.isTypeOf("string",this.metadataKey,!0)&&d.isArrayOf("string",this.metadataValues,!0)&&d.isTypeOf("string",this.metadataValueStartsWith,!0)}serialize(){return d.serialize(this)}next(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw d.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const e=Ae.of(this._iid),{channels:t,token:s}=yield e.getMyGroupChannels(this._token,d.undefineNullProps(Object.assign({},this)),this.limit);return this._token=s,this._hasNext=!!s,this._isLoading=!1,t}return[]}throw d.SendbirdError.invalidParameters}))}}class ye{constructor({top:e=Number.MAX_SAFE_INTEGER,bottom:t=0}){this.top=e,this.bottom=t}includes(...e){return e.every((e=>this.top<=e&&e<=this.bottom))}overlap(e){return this.includes(e.top)||this.includes(e.bottom)}intersect(...e){return e.some((e=>this.top<=e&&e<=this.bottom))}extends(...e){this.top=Math.min(this.top,...e),this.bottom=Math.max(this.bottom,...e)}}class Se extends d.WebSocketEventCommand{constructor(e,t,s){var n;super(e,"SYEV",s),this.pinnedMessageIds=[],this.latestPinnedMessage=null,this.ts=0,s.data&&(this.pinnedMessageIds=null!==(n=s.data.pinned_message_ids)&&void 0!==n?n:[],this.latestPinnedMessage=s.data.latest_pinned_message?_.parseMessagePayload(e,Object.assign({},s.data.latest_pinned_message)):null),this.ts=s.ts}}const be={};class Ae{constructor(e,{sdkState:t,cacheContext:s,dispatcher:n,sessionManager:i,requestQueue:a,logger:r,disableMack:o=!1}){return this._leftChannels=new Map,this._disableMack=!1,this._markAsReadAllLastSentAt=0,be[e]||(this._iid=e,this._sdkState=t,this._sessionManager=i,this._requestQueue=a,this._dispatcher=n,this._logger=r,this._disableMack=o,this._groupChannelHandlers=new Map,this._groupChannelCache=new v(this._iid,{sdkState:t,cacheContext:s}),this._unsentMessageCache=new u.UnsentMessageCache(this._iid,{sdkState:t,cacheContext:s}),this._messageCache=new u.MessageCache(this._iid,{sdkState:t,cacheContext:s,unsentMessageCache:this._unsentMessageCache}),this._groupChannelBroadcast=new I({groupChannelCache:this._groupChannelCache,messageCache:this._messageCache,unsentMessageCache:this._unsentMessageCache,dispatcher:n}),this._messageBroadcast=new O({cacheContext:s,messageCache:this._messageCache,unsentMessageCache:this._unsentMessageCache,dispatcher:n,logger:r}),setInterval((()=>{for(const e of this._groupChannelCache.channels)e.invalidateTypingStatus()&&(this._dispatcher.dispatch(new u.GroupChannelUpdateEventCommand({channels:[e],source:u.GroupChannelEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),this._groupChannelHandlers.forEach((t=>{t.onTypingStatusUpdated&&t.onTypingStatusUpdated(e)})))}),1e3),this._dispatcher.on((e=>{e instanceof d.WebSocketEventCommand?this._handleEvent(e):e instanceof u.AutoResendRequestCommand?(()=>{d.__awaiter(this,void 0,void 0,(function*(){const{message:t}=e,s=yield this.getChannel(t.channelUrl,!0);t instanceof _.UserMessage?s._autoResendUserMessage(t):t instanceof _.FileMessage&&s._autoResendFileMessage(t)}))})():e instanceof u.ReduceDBSizeEventCommand&&this.reduceDBSize()})),be[e]=this),be[e]}static of(e){return be[e]}static clear(e){be[e]&&delete be[e]}get handlers(){return[...this._groupChannelHandlers.values()]}buildGroupChannelFromSerializedData(e){const t=d.deserialize(e);return new Ot(this._iid,Ot.payloadify(t))}buildGroupChannelListQueryFromSerializedData(e){const t=d.deserialize(e);return new Me(this._iid,t)}buildMemberFromSerializedData(e){const t=d.deserialize(e);return new m(this._iid,m.payloadify(t))}getChannelFromCache(e){var t;return d.__awaiter(this,void 0,void 0,(function*(){return null!==(t=yield this._groupChannelCache.get(e))&&void 0!==t?t:null}))}getChannelsFromCache(e,t,s,n,i){return d.__awaiter(this,void 0,void 0,(function*(){return yield this._groupChannelCache.fetch({token:e,filter:t,order:s,limit:n,borderlineChannelUrl:i})}))}upsertChannelsToCache(e){return d.__awaiter(this,void 0,void 0,(function*(){return yield this._groupChannelCache.upsert(e)}))}removeChannelsFromCache(e){return d.__awaiter(this,void 0,void 0,(function*(){yield this._groupChannelCache.remove(e)}))}clearChannelsFromCache(){return d.__awaiter(this,void 0,void 0,(function*(){yield this._groupChannelCache.clear()}))}reduceDBSize(){return d.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:e}=d.Vault.of(this._iid),{localCacheConfig:t,nestdb:s}=e;if(!e.localCacheEnabled||!s||s.state!=u.NestDBState.OPENED)return;const n=1024*t.maxSize*1024;let i=yield s.estimateUsage();if(id.__awaiter(this,void 0,void 0,(function*(){const t=new fe(e);this._requestQueue.send(t)}))));const s=this._groupChannelCache.isCachedInMemory(e.channelUrl),a=e instanceof _.SendableMessage&&e.sender.userId===this._sdkState.userId,r=yield this.getChannel(e.channelUrl,!0);if(r.hiddenState===exports.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE&&(r.hiddenState=exports.HiddenState.UNHIDDEN),e instanceof _.SendableMessage){const{useMemberInfoInMessage:s}=d.Vault.of(this._iid);for(const t of r.members)if(t.userId===e.sender.userId){s||(e.sender.nickname=t.nickname,e.sender.plainProfileUrl=t.plainProfileUrl,e.sender.metaData=t.metaData,e.sender.isBlockedByMe=t.isBlockedByMe);break}if(!s&&n&&(null===(t=e.mentionedUsers)||void 0===t||t.forEach((e=>{for(const t of r.members)if(e.userId===t.userId){e.nickname=t.nickname,e.plainProfileUrl=t.plainProfileUrl,e.metaData=t.metaData;break}}))),a){const{currentUser:t}=this._sessionManager;t&&(t.nickname=e.sender.nickname,t.plainProfileUrl=e.sender.plainProfileUrl,t.metaData=e.sender.metaData)}}e.silent&&!a||(r.isEphemeral||s)&&((!r.lastMessage||r.lastMessage.createdAtd.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(r)})))),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[e],source:d.MessageEventSource.EVENT_MESSAGE_RECEIVED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onMessageReceived&&t.onMessageReceived(r,e),n&&t.onMentionReceived&&t.onMentionReceived(r,e)}))))}}break}case"MEDI":case"FEDI":case"AEDI":{let t=null;if("MEDI"===e.code?t=e.as(h.UpdateUserMessageEventCommand):"FEDI"===e.code?t=e.as(h.UpdateFileMessageEventCommand):"AEDI"===e.code&&(t=e.as(c.UpdateAdminMessageEventCommand)),t){const{message:e,mentionCountChange:s}=t;if(e.channelType===d.ChannelType.GROUP){const t=this._groupChannelCache.isCachedInMemory(e.channelUrl),n=yield this.getChannel(e.channelUrl,!0),i=e instanceof _.SendableMessage&&e.sender.userId===this._sdkState.userId;let a=!1;if(i){const t=e.sender,{currentUser:s}=this._sessionManager;s&&(s.nickname=t.nickname,s.plainProfileUrl=t.plainProfileUrl,s.metaData=t.metaData)}else n.isReadMessage(e)||0!==s&&!e.silent&&t&&(n._updateUnreadCount(n.unreadMessageCount,n.unreadMentionCount+s),a=!0);!n.lastMessage||n.lastMessage.createdAtd.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(n)})))),r&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(n)}))))),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[e],source:d.MessageEventSource.EVENT_MESSAGE_UPDATED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onMessageUpdated&&t.onMessageUpdated(n,e),0!==s&&t.onMentionReceived&&t.onMentionReceived(n,e)}))))}}break}case"DELM":{const{channelUrl:t,channelType:s,messageId:n}=e.as(h.DeleteMessageEventCommand);if(s===d.ChannelType.GROUP){const e=yield this.getChannel(t,!0);this._dispatcher.dispatch(new d.MessageRemoveEventCommand({messageIds:[n],source:d.MessageEventSource.EVENT_MESSAGE_DELETED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onMessageDeleted&&t.onMessageDeleted(e,n)}))))}break}case"READ":{const{readStatus:t}=e.as(de);if(t.channelType===d.ChannelType.GROUP){const e=this._groupChannelCache.isCachedInMemory(t.channelUrl),s=yield this.getChannel(t.channelUrl,!0);e&&s._updateUnreadMemberState(t.reader.userId,t.readAt),t.reader.userId===this._sdkState.userId?e?(s.unreadMessageCount>0||s.unreadMentionCount>0)&&(s._updateUnreadCount(0,0),this._dispatcher.dispatch(new u.GroupChannelUpdateEventCommand({channels:[s],source:u.GroupChannelEventSource.EVENT_CHANNEL_READ})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(s)}))))):0!==s.unreadMessageCount&&0!==s.unreadMentionCount||(this._dispatcher.dispatch(new u.GroupChannelUpdateEventCommand({channels:[s],source:u.GroupChannelEventSource.EVENT_CHANNEL_READ})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(s)}))))):(this._dispatcher.dispatch(new u.GroupChannelUpdateEventCommand({channels:[s],source:u.GroupChannelEventSource.EVENT_CHANNEL_READ})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onUnreadMemberStatusUpdated&&e.onUnreadMemberStatusUpdated(s)})))))}break}case"DLVR":{const{channelUrl:t,deliveredStateUpdate:s={}}=e.as(ue),n=this._groupChannelCache.isCachedInMemory(t),i=yield this.getChannel(t,!0);if(n)for(const e in s)i._updateUndeliveredMemberState(e,s[e]);Object.keys(s).some((e=>e!==this._sdkState.userId))&&(this._dispatcher.dispatch(new u.GroupChannelUpdateEventCommand({channels:[i],source:u.GroupChannelEventSource.EVENT_CHANNEL_DELIVERED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onUndeliveredMemberStatusUpdated&&e.onUndeliveredMemberStatusUpdated(i)})))));break}case"MRCT":{const{channelUrl:t,channelType:s,event:n}=e.as(c.ReactionEventCommand);if(s===d.ChannelType.GROUP){const e=yield this.getChannel(t,!0),s=yield this.getMessageFromCache(n.messageId);s&&(s.applyReactionEvent(n),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[s],source:d.MessageEventSource.EVENT_MESSAGE_REACTION_UPDATED}))),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const t of this._groupChannelHandlers.values())t.onReactionUpdated&&t.onReactionUpdated(e,n)}))))}break}case"MTHD":{const{event:t}=e.as(c.ThreadInfoUpdateEventCommand);if(t.channelType===d.ChannelType.GROUP){const e=yield this.getChannel(t.channelUrl,!0),s=yield this.getMessageFromCache(t.targetMessageId);s&&(s.applyThreadInfoUpdateEvent(t),this._dispatcher.dispatch(new d.MessageUpdateEventCommand({messages:[s],source:d.MessageEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const s of this._groupChannelHandlers.values())s.onThreadInfoUpdated&&s.onThreadInfoUpdated(e,t)}))))}break}case"MCNT":{const{groupChannelMemberCounts:t}=e.as(c.MemberCountUpdateEventCommand),s=[];for(const e of t){const{channelUrl:t,memberCount:n,joinedMemberCount:i,updatedAt:a}=e,r=yield this.getChannelFromCache(t);r&&r._setLatestMemberCount(n,i,a)&&s.push(r)}s.length>0&&(this._dispatcher.dispatch(new u.GroupChannelUpdateEventCommand({channels:s,source:u.GroupChannelEventSource.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged(s)})))));break}case"PEDI":{const{event:t,status:s,channelUrl:n,channelType:i}=e.as(c.PollUpdateEventCommand);if(n&&i===d.ChannelType.GROUP){const e=yield this.getChannel(n,!0);this._dispatcher.dispatch(new d.PollUpdateInternalEventCommand({event:t,source:d.MessageEventSource.EVENT_POLL_UPDATED})),s===d.POLL_REMOVED_STATUS?d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const s of this._groupChannelHandlers.values())s.onPollDeleted&&s.onPollDeleted(e,t.pollId)})))):d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const s of this._groupChannelHandlers.values())s.onPollUpdated&&s.onPollUpdated(e,t)}))))}break}case"VOTE":{const{event:t,channelUrl:s,channelType:n}=e.as(h.PollVoteEventCommand);if(s&&n===d.ChannelType.GROUP){const e=yield this.getChannel(s,!0);this._dispatcher.dispatch(new d.PollVoteInternalEventCommand({event:t,source:d.MessageEventSource.EVENT_POLL_VOTED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const s of this._groupChannelHandlers.values())s.onPollVoted&&s.onPollVoted(e,t)}))))}break}case"SYEV":{const{event:t}=e.as(c.ChannelEventCommand);if(t.isGroupChannelEvent)switch(t.category){case c.ChannelEventCategory.CHANNEL_JOIN:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,members:a}=e.as(ee);let r=!1;a.forEach((e=>{s.isExclusive||s.isSuper||s.isBroadcast?r=r||s._setLatestMemberCount(n,i,t.ts):(e.state=exports.MemberState.JOINED,s.addMember(e,t.ts),this._updateJoinedMemberCount(s)),e.userId===this._sdkState.userId&&(s.myMemberState=exports.MemberState.JOINED)})),this._dispatcher.dispatch(new u.GroupChannelUpdateEventCommand({channels:[s],source:u.GroupChannelEventSource.EVENT_CHANNEL_JOINED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{for(const t of a)e.onUserJoined&&e.onUserJoined(s,t);s.isBroadcast&&r&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([s])}))}))));break}case c.ChannelEventCategory.CHANNEL_LEAVE:{const s=this._leftChannels.get(t.channelUrl),n=s?s.channel:yield this.getChannel(t.channelUrl,!0),{memberCount:i,joinedMemberCount:a,member:r}=e.as(se);let o=!1;const{appInfo:l}=d.Vault.of(this._iid);if(n.isExclusive||n.isSuper||n.isBroadcast)o=n._setLatestMemberCount(i,a,t.ts);else{if(null==l?void 0:l.enabledChannelMemberShipHistory){const e=n.members.find((t=>t.userId===e.userId));e&&(e.state=exports.MemberState.LEFT),n.memberCount=i}else n.removeMember(r);this._updateJoinedMemberCount(n)}r.userId===this._sdkState.userId?(n.myMemberState=exports.MemberState.NONE,n.invitedAt=0,n.joinedAt=0,n._updateUnreadCount(0,0),n.isPublic?this._dispatcher.dispatch(new u.GroupChannelUpdateEventCommand({channels:[n],source:u.GroupChannelEventSource.EVENT_CHANNEL_LEFT})):(this._markAsLeave(n),this._dispatcher.dispatch(new u.GroupChannelRemoveEventCommand({channelUrls:[n.url],source:u.GroupChannelEventSource.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new u.GroupChannelUpdateEventCommand({channels:[n],source:u.GroupChannelEventSource.EVENT_CHANNEL_LEFT})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserLeft&&e.onUserLeft(n,r),n.isBroadcast&&o&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([n])}))}))));break}case c.ChannelEventCategory.CHANNEL_OPERATOR_UPDATE:{const s=yield this.getChannel(t.channelUrl,!0),{operators:n}=e.as(c.OperatorUpdateEventCommand),i=n.map((e=>e.userId));for(const e of s.members)e.role=i.includes(e.userId)?d.Role.OPERATOR:d.Role.NONE;s.myRole=i.includes(this._sdkState.userId)?d.Role.OPERATOR:d.Role.NONE,this._dispatcher.dispatch(new u.GroupChannelUpdateEventCommand({channels:[s],source:u.GroupChannelEventSource.EVENT_CHANNEL_OPERATOR_UPDATED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onOperatorUpdated&&e.onOperatorUpdated(s,n)}))}))));break}case c.ChannelEventCategory.CHANNEL_INVITE:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,inviter:a,invitees:r}=e.as(ae);r.forEach((e=>e.state=exports.MemberState.INVITED));for(const e of r)s.isExclusive||s.isSuper||s.isBroadcast?s._setLatestMemberCount(n,i,t.ts):s.addMember(e,t.ts),this._sdkState.userId===e.userId&&(s.hiddenState=exports.HiddenState.UNHIDDEN,s.myMemberState!==exports.MemberState.JOINED&&(s.myMemberState=exports.MemberState.INVITED),s.invitedAt=t.ts);this._dispatcher.dispatch(new u.GroupChannelUpdateEventCommand({channels:[s],source:u.GroupChannelEventSource.EVENT_CHANNEL_INVITED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserReceivedInvitation&&e.onUserReceivedInvitation(s,a,r)}))}))));break}case c.ChannelEventCategory.CHANNEL_DECLINE_INVITE:{const s=yield this.getChannel(t.channelUrl,!0),{memberCount:n,joinedMemberCount:i,inviter:a,invitee:r}=e.as(oe);s.isExclusive||s.isSuper||s.isBroadcast?s._setLatestMemberCount(n,i,t.ts):s.removeMember(r),this._sdkState.userId===r.userId?(s.invitedAt=0,s.myMemberState=exports.MemberState.NONE,s.isPublic?this._dispatcher.dispatch(new u.GroupChannelUpdateEventCommand({channels:[s],source:u.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new u.GroupChannelRemoveEventCommand({channelUrls:[s.url],source:u.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new u.GroupChannelUpdateEventCommand({channels:[s],source:u.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(s,a,r)}))}))));break}case c.ChannelEventCategory.TYPING_START:case c.ChannelEventCategory.TYPING_END:{const s=yield this.getChannel(t.channelUrl,!0),n=t.category===c.ChannelEventCategory.TYPING_START,{user:i}=e.as(n?Ce:Ee);s._updateTypingStatus(i,n?t.ts:0),this._dispatcher.dispatch(new u.GroupChannelUpdateEventCommand({channels:[s],source:u.GroupChannelEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onTypingStatusUpdated&&e.onTypingStatusUpdated(s)}))}))));break}case c.ChannelEventCategory.USER_CHANNEL_MUTE:case c.ChannelEventCategory.USER_CHANNEL_UNMUTE:{const s=yield this.getChannel(t.channelUrl,!0),n=t.category===c.ChannelEventCategory.USER_CHANNEL_MUTE,{user:i}=e.as(n?h.MuteUserEventCommand:h.UnmuteUserEventCommand);i.userId===this._sdkState.userId&&(s.myMutedState=n?exports.MutedState.MUTED:exports.MutedState.UNMUTED,s._myMutedRemainingTime=i.restrictionInfo.remainingDuration);for(const e of s.members)if(e.userId===i.userId){e.isMuted=n;break}this._dispatcher.dispatch(new u.GroupChannelUpdateEventCommand({channels:[s],source:n?u.GroupChannelEventSource.EVENT_CHANNEL_MUTED:u.GroupChannelEventSource.EVENT_CHANNEL_UNMUTED,data:i.userId})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{n?e.onUserMuted&&e.onUserMuted(s,i):e.onUserUnmuted&&e.onUserUnmuted(s,i)}))}))));break}case c.ChannelEventCategory.USER_CHANNEL_BAN:{const s=this._leftChannels.get(t.channelUrl),n=s?s.channel:yield this.getChannel(t.channelUrl,!0);this._markAsLeave(n);const{user:i}=e.as(h.BanUserEventCommand);i.userId===this._sdkState.userId&&this._dispatcher.dispatch(new u.GroupChannelRemoveEventCommand({channelUrls:[n.url],source:u.GroupChannelEventSource.EVENT_CHANNEL_BANNED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserBanned&&e.onUserBanned(n,i)}))}))));break}case c.ChannelEventCategory.USER_CHANNEL_UNBAN:{const s=yield this.getChannel(t.channelUrl,!0),{user:n}=e.as(h.UnbanUserEventCommand);d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onUserUnbanned&&e.onUserUnbanned(s,n)}))}))));break}case c.ChannelEventCategory.CHANNEL_FREEZE:case c.ChannelEventCategory.CHANNEL_UNFREEZE:{const s=yield this.getChannel(t.channelUrl,!0),{freeze:n}=e.as(h.FreezeEventCommand);s.isFrozen=n,this._dispatcher.dispatch(new u.GroupChannelUpdateEventCommand({channels:[s],source:n?u.GroupChannelEventSource.EVENT_CHANNEL_FROZEN:u.GroupChannelEventSource.EVENT_CHANNEL_UNFROZEN})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{n?e.onChannelFrozen&&e.onChannelFrozen(s):e.onChannelUnfrozen&&e.onChannelUnfrozen(s)}))}))));break}case c.ChannelEventCategory.CHANNEL_HIDE:{const s=yield this.getChannel(t.channelUrl,!0),{allowAutoUnhide:n,hidePreviousMessages:i,messageOffsetTimestamp:a}=e.as(me);null!==n&&(s.hiddenState=n?exports.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:exports.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),null!==i&&i&&s._updateUnreadCount(0,0),null!==a&&(s.messageOffsetTimestamp=a),this._dispatcher.dispatch(new u.GroupChannelUpdateEventCommand({channels:[s],source:u.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onChannelHidden&&e.onChannelHidden(s)}))}))));break}case c.ChannelEventCategory.CHANNEL_UNHIDE:{const e=yield this.getChannel(t.channelUrl,!0);e.hiddenState=exports.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new u.GroupChannelUpdateEventCommand({channels:[e],source:u.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((t=>{t.onChannelChanged&&t.onChannelChanged(e)}))}))));break}case c.ChannelEventCategory.CHANNEL_DELETED:{const e=yield this.getChannel(t.channelUrl,!0);this._dispatcher.dispatch(new u.GroupChannelRemoveEventCommand({channelUrls:[t.channelUrl],source:u.GroupChannelEventSource.EVENT_CHANNEL_DELETED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((t=>{t.onChannelDeleted&&t.onChannelDeleted(e.url,e.channelType)}))}))));break}case c.ChannelEventCategory.CHANNEL_PROP_CHANGED:{const e=yield this.getChannelWithoutCache(t.channelUrl,!0);this._dispatcher.dispatch(new u.GroupChannelUpdateEventCommand({channels:[e],source:u.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((t=>{t.onChannelChanged&&t.onChannelChanged(e)}))}))));break}case c.ChannelEventCategory.CHANNEL_META_DATA_CHANGED:{const s=yield this.getChannel(t.channelUrl,!0),{created:n,updated:i,deleted:a}=e.as(h.UpdateMetaDataEventCommand);n&&s._upsertCachedMetaData(n,t.ts),i&&s._upsertCachedMetaData(i,t.ts),a&&s._removeFromCachedMetaData(a,t.ts),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{n&&e.onMetaDataCreated&&e.onMetaDataCreated(s,n),i&&e.onMetaDataUpdated&&e.onMetaDataUpdated(s,i),a&&e.onMetaDataDeleted&&e.onMetaDataDeleted(s,a)}))}))));break}case c.ChannelEventCategory.CHANNEL_META_COUNTERS_CHANGED:{const s=yield this.getChannel(t.channelUrl,!0),{created:n,updated:i,deleted:a}=e.as(h.UpdateMetaCounterEventCommand);d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{n&&e.onMetaCounterCreated&&e.onMetaCounterCreated(s,n),i&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(s,i),a&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(s,a)}))}))));break}case c.ChannelEventCategory.PINNED_MESSAGE_CHANGED:{const s=yield this.getChannel(t.channelUrl,!0),{pinnedMessageIds:n,latestPinnedMessage:i,ts:a}=e.as(Se);a>s._pinnedMessagesUpdatedAt&&(s.pinnedMessageIds=n,s.lastPinnedMessage=i,s._pinnedMessagesUpdatedAt=a,this._dispatcher.dispatch(new u.GroupChannelUpdateEventCommand({channels:[s],source:u.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED})),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){for(const e of this._groupChannelHandlers.values())e.onChannelChanged&&e.onChannelChanged(s)})))),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){this._groupChannelHandlers.forEach((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(s)}))})))));break}}break}case"USEV":{const{event:t}=e.as(u.UserEventCommand);switch(t.category){case u.UserEventCategory.USER_BLOCK:{const{blocker:e,blockee:s}=u.UserEvent.getDataAsUserBlockEvent(this._iid,t);this._groupChannelCache.block(e.userId,s.userId);break}case u.UserEventCategory.USER_UNBLOCK:{const{blocker:e,blockee:s}=u.UserEvent.getDataAsUserBlockEvent(this._iid,t);this._groupChannelCache.unblock(e.userId,s.userId);break}}break}}}catch(e){if(d.isThrowingOutside(e))throw e}}))}_markAsLeave(e){var t;const s=null!==(t=this._leftChannels.get(e.url))&&void 0!==t?t:{channel:e,ref:0};s.ref++,this._leftChannels.set(e.url,s),setTimeout((()=>{s.ref--,0===s.ref&&this._leftChannels.delete(e.url)}),1e4)}addHandler(e,t){this._groupChannelHandlers.set(e,t)}removeHandler(e){this._groupChannelHandlers.delete(e)}clearHandler(){this._groupChannelHandlers.clear()}subscribeGroupChannelEvent(e,t){this._groupChannelBroadcast.subscribe(e,t)}unsubscribeGroupChannelEvent(e){this._groupChannelBroadcast.unsubscribe(e)}subscribeMessageEvent(e,t){this._messageBroadcast.subscribe(e,t)}unsubscribeMessageEvent(e){this._messageBroadcast.unsubscribe(e)}_updateJoinedMemberCount(e){e.joinedMemberCount=e.members.filter((e=>e.state===exports.MemberState.JOINED)).length}getChannel(e,t=!1){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isTypeOf("string",e)).throw(d.SendbirdError.invalidParameters);try{const t=yield this.getChannelFromCache(e);if(t)return t}catch(e){}return yield this.getChannelWithoutCache(e,t)}))}getChannelWithoutCache(e,t=!1){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isTypeOf("string",e)).throw(d.SendbirdError.invalidParameters);const s=new x({channelUrl:e,isInternalCall:t}),n=yield this._requestQueue.send(s),{channel:i}=n.as(R);let{unreadMessageCount:a,unreadMentionCount:r}=i;switch(i.myCountPreference){case exports.CountPreference.UNREAD_MESSAGE_COUNT_ONLY:r=0;break;case exports.CountPreference.UNREAD_MENTION_COUNT_ONLY:a=0;break;case exports.CountPreference.OFF:a=0,r=0}return i._updateUnreadCount(a,r),(yield this.upsertChannelsToCache([i]))[0]}))}refreshChannel(e,t=!0,s=u.GroupChannelEventSource.REFRESH_CHANNEL){return d.__awaiter(this,void 0,void 0,(function*(){try{const n=new x({channelUrl:e,isInternalCall:t}),i=yield this._requestQueue.send(n),{channel:a}=i.as(R);if(a.myMemberState===exports.MemberState.NONE)this._dispatcher.dispatch(new u.GroupChannelRemoveEventCommand({channelUrls:[a.url],source:s}));else{const e=yield this.upsertChannelsToCache([a]);this._dispatcher.dispatch(new u.GroupChannelUpdateEventCommand({channels:e,source:s}))}}catch(t){t.code!==d.SendbirdErrorCode.NON_AUTHORIZED&&t.code!==d.SendbirdErrorCode.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new u.GroupChannelRemoveEventCommand({channelUrls:[e],source:s}))}}))}getMyGroupChannels(e,t,s,n=u.GroupChannelEventSource.REQUEST_CHANNEL){return d.__awaiter(this,void 0,void 0,(function*(){const i=new F(Object.assign(Object.assign({},t),{userId:this._sdkState.userId,token:e,limit:s})),a=yield this._requestQueue.send(i),{channels:r,token:o}=a.as(k);return this._dispatcher.dispatch(new u.GroupChannelUpdateEventCommand({channels:r,source:n})),{channels:r,token:o}}))}getMessageFromCache(e){var t;return d.__awaiter(this,void 0,void 0,(function*(){return null!==(t=yield this._messageCache.get(e))&&void 0!==t?t:null}))}_getExactlyMatchingMessagesForTokenFromCache(e,t,s){return d.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.fetch({channelUrl:e,token:t,filter:s,exactMatch:!0})}))}getMessagesFromCache(e,t,s,n,i=h.DEFAULT_MESSAGE_LIMIT,a=!0){return d.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.fetch({channelUrl:e,token:t,limit:i,filter:n,backward:"next"===s,inclusive:a})}))}getPollMessagesFromCache(e,t,s,n=h.DEFAULT_MESSAGE_LIMIT){return d.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.fetch({channelUrl:e,token:t,limit:n,filter:s,backward:!1,isPollOnly:!0})}))}getUnsentMessagesFromCache(e,t){return d.__awaiter(this,void 0,void 0,(function*(){return yield this._unsentMessageCache.fetch({channelUrl:e,filter:t})}))}removeFailedMessageFromCache(e){return d.__awaiter(this,void 0,void 0,(function*(){yield this._unsentMessageCache.remove([e])}))}getCachedMessageCountBetween(e,t,s,n){return d.__awaiter(this,void 0,void 0,(function*(){return yield this._messageCache.countBetween(e,t,new ye({top:s,bottom:n}))}))}getMyGroupChannelChangeLogs(e,t,s=u.GroupChannelEventSource.REQUEST_CHANNEL_CHANGELOGS){return d.__awaiter(this,void 0,void 0,(function*(){const n=Object.assign(Object.assign({},M),t);d.unless((d.isTypeOf("string",e)||d.isTypeOf("number",e))&&y(n)).throw(d.SendbirdError.invalidParameters);const i=new P(d.undefineNullProps({userId:this._sdkState.userId,ts:"number"==typeof e?e:null,token:"string"==typeof e?e:null,filter:n})),a=(yield this._requestQueue.send(i)).as(w),{updatedChannels:r,deletedChannelUrls:o,hasMore:l}=a;return r.length>0&&this._dispatcher.dispatch(new u.GroupChannelUpdateEventCommand({channels:r,source:s})),o.length>0&&this._dispatcher.dispatch(new u.GroupChannelRemoveEventCommand({channelUrls:o,source:s})),{updatedChannels:r,deletedChannelUrls:o,hasMore:l,token:a.token}}))}getGroupChannelCount(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},S),e);d.unless(b(t)).throw(d.SendbirdError.invalidParameters);const s=new D({userId:this._sdkState.userId,filter:t}),n=yield this._requestQueue.send(s),{groupChannelCount:i}=n.as(G);return i}))}getUnreadItemCount(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},U),e);d.unless((e=>d.isArrayOf(exports.UnreadItemKey,e.keys))(t)).throw(d.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new H({userId:s.userId,filter:t}),a=yield n.send(i),{groupChannelUnreadMentionCount:r,groupChannelUnreadMessageCount:o,groupChannelInvitationCount:l,superGroupChannelUnreadMentionCount:h,superGroupChannelUnreadMessageCount:u,superGroupChannelInvitationCount:c,nonSuperGroupChannelUnreadMentionCount:_,nonSuperGroupChannelUnreadMessageCount:p,nonSuperGroupChannelInvitationCount:m}=a.as(V);return d.deundefined({groupChannelUnreadMentionCount:r,groupChannelUnreadMessageCount:o,groupChannelInvitationCount:l,superGroupChannelUnreadMentionCount:h,superGroupChannelUnreadMessageCount:u,superGroupChannelInvitationCount:c,nonSuperGroupChannelUnreadMentionCount:_,nonSuperGroupChannelUnreadMessageCount:p,nonSuperGroupChannelInvitationCount:m})}))}getTotalUnreadChannelCount(){return d.__awaiter(this,void 0,void 0,(function*(){const{sdkState:e,requestQueue:t}=d.Vault.of(this._iid),s=new q({userId:e.userId}),n=yield t.send(s),{unreadCount:i}=n.as(j);return i}))}getTotalUnreadMessageCount(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},T),e);d.unless((e=>d.isArrayOf("string",e.channelCustomTypesFilter,!0)&&d.isEnumOf(exports.SuperChannelFilter,e.superChannelFilter))(t)).throw(d.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new B({userId:s.userId,filter:t}),a=yield n.send(i),{unreadCount:r}=a.as(W);return r}))}getTotalScheduledMessageCount(e={}){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},N),e);d.unless((e=>d.isTypeOf("string",e.channelUrl,!0)&&d.isArrayOf(_.ScheduledStatus,e.scheduledStatus,!0)&&d.isEnumOf(d.MessageTypeFilter,e.messageTypeFilter))(t)).throw(d.SendbirdError.invalidParameters);const{requestQueue:s}=d.Vault.of(this._iid),n=new $(t),i=yield s.send(n),{count:a}=i.as(z);return a}))}getSubscribedTotalUnreadMessageCount(){const{subscribedUnreadMessageCount:e}=d.Vault.of(this._iid);return e.all>=0?e.all:0}getSubscribedCustomTypeTotalUnreadMessageCount(){let e=0;const{subscribedUnreadMessageCount:t}=d.Vault.of(this._iid);for(const s in t.customTypes)e+=t.customTypes[s];return e}getSubscribedCustomTypeUnreadMessageCount(e){var t;const{subscribedUnreadMessageCount:s}=d.Vault.of(this._iid);return null!==(t=s.customTypes[e])&&void 0!==t?t:0}createChannel(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},E),e);d.unless(f(t)).throw(d.SendbirdError.invalidParameters),t.isPublic||(t.accessCode=void 0);const s=new K(Object.assign({userId:this._sdkState.userId},t)),n=yield this._requestQueue.send(s),{channel:i}=n.as(Y);return yield this.upsertChannelsToCache([i]),i}))}markAsReadAll(){return d.__awaiter(this,void 0,void 0,(function*(){const e=Date.now();d.unless(e-this._markAsReadAllLastSentAt>=1e3).throw(d.SendbirdError.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=e;const t=new J({userId:this._sdkState.userId});yield this._requestQueue.send(t);const s=this._groupChannelCache.channels;for(const t of s)t._updateUnreadMemberState(this._sdkState.userId,e),t._updateUnreadCount(0,0);s.length>0&&(yield this.upsertChannelsToCache(s))}))}markAsReadWithChannelUrls(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Date.now();d.unless(d.isArrayOf("string",e)&&t-this._markAsReadAllLastSentAt>=1e3).throw(d.SendbirdError.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t;const s=new J({userId:this._sdkState.userId,channelUrls:e});yield this._requestQueue.send(s);const n=this._groupChannelCache.channels,i=[];for(const s of n)e.includes(s.url)&&(s._updateUnreadMemberState(this._sdkState.userId,t),s._updateUnreadCount(0,0),i.push(s));i.length>0&&(yield this.upsertChannelsToCache(i))}))}markAsDelivered(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getChannel(e);yield t.markAsDelivered()}))}}var Ue;!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(Ue||(Ue={}));class Te extends d.EventDispatcher{constructor(e,t,s=2,n=10){super(),this._state=Ue.IDLE,this._retryCount=0,this._retryLimit=3,this.priority=0,this._worker=t}get isIdle(){return this._state===Ue.IDLE}get isRunning(){return this._state===Ue.RUNNING}get isDone(){return this._state===Ue.END}get retryCount(){return this._retryCount}get retryLimit(){return this._retryLimit}_run(e){return d.__awaiter(this,void 0,void 0,(function*(){if(this.isRunning)try{const t=yield this._worker(e);this._retryCount=0,this.dispatch("progress",t),t.hasNext?this._run(t.nextToken):this.end()}catch(t){this.dispatch("error",t),this._retryCount`sendbird:${e}@groupchannel/${t}/message/sync`)(n.userId,t.url);this._prevSync=new Te(l,(e=>d.__awaiter(this,void 0,void 0,(function*(){var t,s,n,i,r;const o={hasNext:!0,nextToken:0};if(this._prevSyncLoopCount++,yield this.loadMetadata(e),a.debug("message background prev sync from",null===(t=this._metadata)||void 0===t?void 0:t.range.top),null===(s=this._metadata)||void 0===s?void 0:s.previousComplete)o.hasNext=!1;else try{const t=_.MessageManager.of(this._iid),s=yield t.getMessagesByTimestamp(this._channel.url,this._channel.channelType,(null===(i=null===(n=this._metadata)||void 0===n?void 0:n.range)||void 0===i?void 0:i.top)?this._metadata.range.top:e,{prevResultSize:this._limit,nextResultSize:0,replyType:d.ReplyType.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0},d.MessageEventSource.SYNC_MESSAGE_BACKGROUND);if(s.length>0){const e=s.map((e=>e.createdAt));(null===(r=this._metadata)||void 0===r?void 0:r.range.intersect(...e))?this.extendRange(s):this._metadata={range:new ye({top:Math.min(...e),bottom:Math.max(...e)}),previousComplete:!1}}o.hasNext=s.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(o.nextToken=this._metadata.range.top,this._metadata.previousComplete=s.lengthd.__awaiter(this,void 0,void 0,(function*(){var t,s,n,i;const r={hasNext:!0,nextToken:0};this._nextSyncLoopCount++,yield this.loadMetadata(e),a.debug("message background next sync from",null===(t=this._metadata)||void 0===t?void 0:t.range.bottom);try{const t=_.MessageManager.of(this._iid),o=yield t.getMessagesByTimestamp(this._channel.url,this._channel.channelType,(null===(n=null===(s=this._metadata)||void 0===s?void 0:s.range)||void 0===n?void 0:n.bottom)?this._metadata.range.bottom:e,{prevResultSize:0,nextResultSize:this._limit,replyType:d.ReplyType.ALL,includeReactions:!0,includeMetaArray:!0,includeParentMessageInfo:!0,includeThreadInfo:!0},d.MessageEventSource.SYNC_MESSAGE_BACKGROUND);if(o.length>0){const e=o.map((e=>e.createdAt));(null===(i=this._metadata)||void 0===i?void 0:i.range.intersect(...e))?this.extendRange(o):this._metadata={range:new ye({top:Math.min(...e),bottom:Math.max(...e)}),previousComplete:!1}}r.hasNext=o.length>=this._limit&&this._nextSyncLoopCount<1,this._metadata&&(r.nextToken=this._metadata.range.bottom),a.debug("message background next sync progress",r),yield this.saveMetadata()}catch(e){throw a.debug("message background next sync error",e),e}return r})))),this._connectionEventContext=i.on((e=>{if(e instanceof d.ConnectionStateChangeCommand)if(e.stateType===d.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e,t){return Oe[e]||(Oe[e]={}),Oe[e][t.url]||(Oe[e][t.url]=new Pe({_iid:e,channel:t})),Oe[e][t.url].ref++,Oe[e][t.url]}static clear(e,t){Oe[e]&&Oe[e][t]&&(Oe[e][t].close(),delete Oe[e])}get range(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new ye({})}get previousComplete(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.previousComplete)}isWrappingMessages(e){var t;return null===(t=this.range)||void 0===t?void 0:t.includes(...e.map((e=>e.createdAt)))}extendRange(e){this._metadata&&this._metadata.range.extends(...e.map((e=>e.createdAt)))}loadMetadata(e){return d.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:t}=d.Vault.of(this._iid),s=yield t.preference.get(this._metadataKey);s?s.range.bottom`sendbird:${e}@groupchannel/${t}/message/changelogs`)(n.userId,this._channel.url);this._sync=new Te(o,(()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const t={hasNext:!0,nextToken:0};yield this.loadMetadata(),s.debug("message changelog sync from",null===(e=this._metadata)||void 0===e?void 0:e.token);try{const e=_.MessageManager.of(this._iid),{updatedMessages:n,deletedMessageIds:i,hasMore:a,token:r}=yield e.getMessageChangelogs(this._channel.url,this._channel.channelType,this._metadata.token,{replyType:d.ReplyType.ALL,includeReactions:!0,includeThreadInfo:!0,includeMetaArray:!0,includeParentMessageInfo:!0},d.MessageEventSource.SYNC_MESSAGE_CHANGELOGS);t.hasNext=a,t.nextToken=r,(n.length>0||i.length>0)&&this._metadata&&(this._metadata.token=r),s.debug("message changelog sync progress",t),yield this.saveMetadata()}catch(e){throw s.debug("message changelog sync error",e),e instanceof d.SendbirdError&&e.isInvalidTokenError&&(yield this.clearMetadata()),e}return t})))),this._connectionEventContext=i.on((e=>{if(e instanceof d.ConnectionStateChangeCommand)if(e.stateType===d.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e,t){return we[e]||(we[e]={}),we[e][t.url]||(we[e][t.url]=new xe({_iid:e,channel:t})),we[e][t.url].ref++,we[e][t.url]}static clear(e,t){we[e]&&we[e][t]&&(we[e][t].close(),delete we[e])}loadMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:e,firstConnectedAt:t}=d.Vault.of(this._iid),s=yield e.preference.get(this._metadataKey);this._metadata={token:s?s.token:t}}return this._metadata}))}saveMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._metadata){const{cacheContext:e}=d.Vault.of(this._iid);return yield e.preference.set(this._metadataKey,this._metadata),!0}return!1}))}clearMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:e}=d.Vault.of(this._iid);yield e.preference.remove(this._metadataKey),this._metadata=void 0}))}resume(){const{logger:e,connectionManager:t}=d.Vault.of(this._iid);t.isConnected&&(e.debug("message changelog sync resume()"),this._sync.start(0))}pause(){const{logger:e,connectionManager:t}=d.Vault.of(this._iid);e.debug("message changelog sync pause()"),this._sync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete we[this._iid][this._channel.url])}}const Re={};class Le{constructor({_iid:e,channel:t,hasPollMessage:s}){this.ref=0,this._iid=e,this._channel=t;const{logger:n,sdkState:i,dispatcher:a}=d.Vault.of(this._iid);var r,o;this._metadataKey=(r=i.userId,o=t.url,`sendbird:${r}@groupchannel/${o}/poll/changelogs.meta`);const l=((e,t)=>`sendbird:${e}@groupchannel/${t}/poll/changelogs`)(i.userId,this._channel.url);this._sync=new Te(l,(()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const t={hasNext:!0,nextToken:0};if(yield this.loadMetadata(),n.debug("poll changelog sync from",null===(e=this._metadata)||void 0===e?void 0:e.token),!(this._metadata&&this._metadata.token||(yield s()))){return{hasNext:!1,nextToken:0}}if(!this._metadata){const{firstConnectedAt:e}=d.Vault.of(this._iid);this._metadata={token:e}}try{const e=p.PollManager.of(this._iid),{hasMore:s,token:i}=yield e.getPollChangeLogs(this._channel.url,this._channel.channelType,this._metadata.token);t.hasNext=s,t.nextToken=i,this._metadata.token=i,n.debug("poll changelog sync progress",t),yield this.saveMetadata()}catch(e){throw n.debug("poll changelog sync error",e),e instanceof d.SendbirdError&&e.isInvalidTokenError&&(yield this.clearMetadata()),e}return t})))),this._connectionEventContext=a.on((e=>{if(e instanceof d.ConnectionStateChangeCommand)if(e.stateType===d.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e,t,s){return Re[e]||(Re[e]={}),Re[e][t.url]||(Re[e][t.url]=new Le({_iid:e,channel:t,hasPollMessage:s})),Re[e][t.url].ref++,Re[e][t.url]}loadMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:e}=d.Vault.of(this._iid),t=yield e.preference.get(this._metadataKey);this._metadata=t?{token:t.token}:void 0}}))}saveMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._metadata){const{cacheContext:e}=d.Vault.of(this._iid);yield e.preference.set(this._metadataKey,this._metadata)}}))}clearMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:e}=d.Vault.of(this._iid);yield e.preference.remove(this._metadataKey),this._metadata=void 0}))}resume(){const{logger:e}=d.Vault.of(this._iid);e.debug("poll changelog sync resume()"),this._sync.start(0)}pause(){const{logger:e}=d.Vault.of(this._iid);e.debug("poll changelog sync pause()"),this._sync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Re[this._iid][this._channel.url])}}class Fe extends d.APIRequestCommand{constructor(e){var t,s,n,i,a,r;super(),this.method=d.APIRequestMethod.GET,this.path=`${d.getChannelApiPathByType(e.channelType)}/${e.channelUrl}/messages_gap`,this.params=d.deundefined({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!==(t=e.threshold)&&void 0!==t?t:null,reverse:!0,custom_types:null!==(s=e.customTypes)&&void 0!==s?s:["*"],message_type:null!==(n=e.messageType)&&void 0!==n?n:null,include_reactions:null===(i=e.includeReactions)||void 0===i||i,with_sorted_meta_array:null===(a=e.includeMetaArray)||void 0===a||a,show_subchannel_messages_only:null!==(r=e.showSubchannelMessagesOnly)&&void 0!==r&&r,include_poll_details:!0,checking_continuous_messages:e.checkingContinuousMessages})}}class ke extends d.APIResponseCommand{constructor(e,t){var s,n,i,a,r,o;super(e,t),this.isHugeGap=t.is_huge_gap,this.prevMessages=(null!==(s=t.prev_messages)&&void 0!==s?s:[]).map((t=>_.parseMessagePayload(e,t))),this.prevHasMore=null!==(n=t.prev_hasmore)&&void 0!==n&&n,this.isContinuousPrevMessages=null!==(i=t.is_continuous_prev_messages)&&void 0!==i&&i,this.nextMessages=(null!==(a=t.next_messages)&&void 0!==a?a:[]).map((t=>_.parseMessagePayload(e,t))),this.nextHasmore=null!==(r=t.next_hasmore)&&void 0!==r&&r,this.isContinuousNextMessages=null!==(o=t.is_continuous_next_messages)&&void 0!==o&&o}}const De=(e,t)=>e.findIndex((e=>e.isIdentical(t))),Ge=(e,t,s)=>{if(e.length>0){const n=De(e,t);let i=0,a=e.length-1,r=Math.floor((i+a)/2);for(;i0)a=r,r=Math.floor((i+a)/2);else{if(!(o<0))return{place:r,oldPosition:n};i=r+1,r=Math.floor((i+a)/2)}}return{place:He(e[r],t,s)>=0?r:r+1,oldPosition:n}}return{place:e.length,oldPosition:-1}},He=(e,t,s)=>{switch(s){case u.GroupChannelListOrder.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 u.GroupChannelListOrder.CHRONOLOGICAL:return t.createdAt-e.createdAt;case u.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:{const s=e.name.localeCompare(t.name);return 0===s?e.createdAt-t.createdAt:s}default:return 0}},Ve=(e,t)=>t instanceof _.SendableMessage?e.findIndex((e=>e instanceof _.SendableMessage&&t.isIdentical(e))):e.findIndex((e=>e.isIdentical(t))),qe=(e,t)=>e.findIndex((e=>e.messageId===t)),je=(e,t)=>{if(e.length>0){let s=0,n=e.length-1,i=Math.floor((s+n)/2);for(;s0)n=i,i=Math.floor((s+n)/2);else{if(!(a<0))return i;s=i+1,i=Math.floor((s+n)/2)}}return e[i].createdAt>t.createdAt?i:i+1}return e.length},Be=6e5;exports.MessageCollectionInitPolicy=void 0,(exports.MessageCollectionInitPolicy||(exports.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";class We{_invokeResponse(e,t,s){d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){switch(e){case"local":this._onCacheResult(t,s);break;case"remote":this._onApiResult(t,s)}}))))}onCacheResult(e){return this._onCacheResult=e,this}onApiResult(e){return this._onApiResult=e,this}}class $e{constructor(e,{channel:t,filter:s,startingPoint:n,limit:i}){this._messages=[],this._unsentMessages=[],this._iid=e,this._key=`mc-${d.uuid()}`,this._isDisposed=!1,this.filter=null!=s?s:new u.MessageFilter,this._channel=t,this._syncRange=new ye({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof n?n:Date.now()+Be,this._limit=i||h.DEFAULT_MESSAGE_LIMIT;const a=Ae.of(this._iid);a.subscribeGroupChannelEvent(this._key,{onUpdate:(e,t,s)=>{const n=De(e,this._channel);if(n>=0){switch(this._channel=e[n],t){case u.GroupChannelEventSource.EVENT_CHANNEL_UPDATED:{let e=!1;for(const t in this._messages){if(this._messages[t].createdAt>=this._channel.messageOffsetTimestamp){e=!0;const s=parseInt(t);if(s>0){const e=this._messages.splice(0,s);this._removeMessagesFromView(e.map((e=>e.messageId)),d.MessageEventSource.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!e&&this._messages.length>0&&this._removeMessagesFromView(this._messages.map((e=>e.messageId)),d.MessageEventSource.EVENT_MESSAGE_OFFSET_UPDATED);break}case u.GroupChannelEventSource.EVENT_CHANNEL_UNMUTED:{const{sdkState:e}=d.Vault.of(this._iid),t=s;e.userId===t&&this._clearCheckMyMutedTimer();break}case u.GroupChannelEventSource.EVENT_CHANNEL_MUTED:{const{sdkState:e}=d.Vault.of(this._iid),t=s;e.userId===t&&-1!==this.channel._myMutedRemainingTime&&this._startCheckMyMutedTimer(this.channel._myMutedRemainingTime);break}case u.GroupChannelEventSource.EVENT_CHANNEL_LEFT:this.channel.isPublic&&this._clearCheckMyMutedTimer()}d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const s=new Ne(t);u.shouldGiveEvent(t)&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelUpdated)&&this._handler.onChannelUpdated(s,this.channel)}))))}},onRemove:(e,t)=>{e.indexOf(this.channel.url)>=0&&(this._clearCheckMyMutedTimer(),d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const s=new Ne(t);(null===(e=this._handler)||void 0===e?void 0:e.onChannelDeleted)&&this._handler.onChannelDeleted(s,this.channel.url)})))))}}),a.subscribeMessageEvent(this._key,{onUpdate:(e,t)=>{const s=[],n=[];for(const t of e)t.channelUrl===this._channel.url&&(this.filter.match(t)?s.push(t):n.push(t.messageId));if(d.shouldGiveEvent(t)){if(s.length>0)switch(t){case d.MessageEventSource.LOCAL_MESSAGE_CANCELED:case d.MessageEventSource.LOCAL_MESSAGE_RESEND_STARTED:case d.MessageEventSource.EVENT_MESSAGE_SENT_FAILED:case d.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS:case d.MessageEventSource.EVENT_MESSAGE_UPDATED:case d.MessageEventSource.EVENT_MESSAGE_THREADINFO_UPDATED:case d.MessageEventSource.EVENT_MESSAGE_REACTION_UPDATED:case d.MessageEventSource.SYNC_MESSAGE_CHANGELOGS:this._updateMessagesToView(s,t);break;case d.MessageEventSource.EVENT_MESSAGE_SENT_PENDING:this._addMessagesToView(s,t);break;case d.MessageEventSource.EVENT_MESSAGE_RECEIVED:this.hasNext||this._addMessagesToView(s,t);break;case d.MessageEventSource.SYNC_MESSAGE_FILL:this._addMessagesToView(s,t)}n.length>0&&this._removeMessagesFromView(n,t)}},onRemove:(e,t)=>{this._removeMessagesFromView(e,t)},onRemoveUnsent:(e,t)=>{this._removeUnsentMessageFromView(e,t)},onPollChangeLogUpdate:(e,t)=>{this._updatePollsToView(e,t)},onPollUpdate:(e,t)=>{this._applyPollUpdateEventToView(e,t)},onPollVote:(e,t)=>{this._applyPollVoteEventToView(e,t)}});const{cacheContext:r,dispatcher:o,logger:l}=d.Vault.of(this._iid);this._channel._updateMessageCollectionLastAccessedAt(),o.dispatch(new u.GroupChannelUpdateEventCommand({channels:[this._channel],source:u.GroupChannelEventSource.CHANNEL_LASTACCESSEDAT_UPDATED})),!this._channel.isSuper&&r.localCacheEnabled&&(this._backgroundSync=Pe.of(this._iid,this._channel),this._backgroundSync.resume(this._startingPoint)),this._changelogSync=xe.of(this._iid,this._channel),this._changelogSync.resume(),this._pollChangelogSync=Le.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new Te(this._key,(e=>d.__awaiter(this,void 0,void 0,(function*(){var t;const{messages:s,isContinuousMessages:n}=yield this._getRemoteMessages(e,{prevLimit:this._limit,source:d.MessageEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:r.localCacheEnabled});if(s.length>0){const e=Math.min(...s.map((e=>e.createdAt)));return this._syncRange.extends(e),n&&(null===(t=this._backgroundSync)||void 0===t||t.range.extends(e)),{hasNext:s.length>=this._limit&&this.viewTopd.__awaiter(this,void 0,void 0,(function*(){var t;const{messages:s,isContinuousMessages:n}=yield this._getRemoteMessages(e,{nextLimit:this._limit,source:d.MessageEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:r.localCacheEnabled});if(s.length>0){const e=Math.max(...s.map((e=>e.createdAt)));return this._syncRange.extends(e),n&&(null===(t=this._backgroundSync)||void 0===t||t.range.extends(e)),{hasNext:!(s.length>=this._limit&&this._hasNext)||this.viewBottom>e,nextToken:this._syncRange.bottom}}return{hasNext:!1,nextToken:0}})))),this._connectionEventContext=o.on((e=>{if(e instanceof d.ConnectionStateChangeCommand)switch(e.stateType){case d.ConnectionStateType.CONNECTED:this._refreshChannel(u.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS),d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){const e=yield this.channel.getMyMutedInfo();e.isMuted&&-1!==e.remainingDuration&&this._startCheckMyMutedTimer(e.remainingDuration)})))),l.debug("check huge gap"),this._checkHugeGap();break;case d.ConnectionStateType.LOGOUT:this.dispose();break;default:this._clearCheckMyMutedTimer(),this._prevFill.stop(),this._nextFill.stop()}}));const{statLogCollector:c}=d.Vault.of(this._iid);c.put(new d.DailyRecordStatLog({type:d.StatType.FEATURE_LOCALCACHE,data:{use_local_cache:r.localCacheEnabled,collection_interface:{message:!0}}}))}get channel(){return this._channel}get succeededMessages(){return[...this._messages]}get failedMessages(){return this._unsentMessages.filter((e=>e.sendingStatus===d.SendingStatus.FAILED))}get pendingMessages(){return this._unsentMessages.filter((e=>e.sendingStatus===d.SendingStatus.PENDING))}get hasPrevious(){return this._hasPrevious}get hasNext(){return this._hasNext}get viewTop(){return Math.min(...this._messages.map((e=>e.createdAt)),Number.MAX_SAFE_INTEGER)}get viewBottom(){return Math.max(...this._messages.map((e=>e.createdAt)),0)}setMessageCollectionHandler(e){this._handler=e}_filterUnderOffsetMessage(e){return e}_addMessagesToView(e,t){const s=this._filterUnderOffsetMessage(e),n=[],i=[];for(const e of s)if(t===d.MessageEventSource.SYNC_MESSAGE_FILL){if(e.messageId>0){if(Ve(this._messages,e)<0){Ve(this._unsentMessages,e)<0&&n.push(e);const t=je(this._messages,e);this._messages.splice(t,0,e)}}else if(e instanceof _.SendableMessage){Ve(this._unsentMessages,e)<0&&Ve(this._messages,e)<0&&(this._unsentMessages.push(e),n.push(e))}}else if(e.messageId>0){const t=Ve(this._messages,e);if(t<0){const t=Ve(this._unsentMessages,e);t<0?n.push(e):(this._unsentMessages.splice(t,1),i.push(e));const s=je(this._messages,e);this._messages.splice(s,0,e)}else i.push(e),this._messages[t]=e;if(e.updatedAt>0){const t=this._updateChildMessagesInView(e);i.push(...t)}}else if(e instanceof _.SendableMessage){const t=Ve(this._unsentMessages,e);t<0?Ve(this._messages,e)<0&&(this._unsentMessages.push(e),n.push(e)):(i.push(e),this._unsentMessages[t]=e)}d.shouldGiveEvent(t)&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,s;const a=new Ie(t);n.length>0&&(null===(e=this._handler)||void 0===e||e.onMessagesAdded(a,this.channel,n)),i.length>0&&(null===(s=this._handler)||void 0===s||s.onMessagesUpdated(a,this.channel,i))}))))}_updateChildMessagesInView(e){const t=[];return this._messages.forEach((s=>{s.parentMessageId===e.messageId&&s.applyParentMessage(e)&&t.push(s)})),t}_updatePollsToView(e,t){const s=[];for(const t of e){const e=qe(this._messages,t.messageId);if(e>=0){const n=this._messages[e];n&&n.applyPoll(t),s.push(n)}}return s.length>0&&d.shouldGiveEvent(t)&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const n=new Ie(t);s.length>0&&(null===(e=this._handler)||void 0===e||e.onMessagesUpdated(n,this.channel,s))})))),s}_applyPollUpdateEventToView(e,t){const s=qe(this._messages,e.messageId);if(s>=0){const n=this._messages[s];n&&n.isUserMessage()&&n.poll&&n.poll.applyPollUpdateEvent(e)&&d.shouldGiveEvent(t)&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const s=new Ie(t);null===(e=this._handler)||void 0===e||e.onMessagesUpdated(s,this.channel,[n])}))))}}_applyPollVoteEventToView(e,t){const s=qe(this._messages,e.messageId);if(s>=0){const n=this._messages[s];n&&n.isUserMessage()&&n.poll&&n.poll.applyPollVoteEvent(e)&&d.shouldGiveEvent(t)&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const s=new Ie(t);null===(e=this._handler)||void 0===e||e.onMessagesUpdated(s,this.channel,[n])}))))}}_updateMessagesToView(e,t){const s=[],n=[],i=[];for(const t of e)if(t.messageId>0){const e=Ve(this._messages,t);if(e>=0)n.push(t),this._messages[e]=t;else{const e=Ve(this._unsentMessages,t);if(e>=0){const s=this._unsentMessages.splice(e,1);if(this.hasNext&&s.length>0)i.push(s[0]);else{n.push(t);const e=je(this._messages,t);this._messages.splice(e,0,t)}}else{const e=this._messages.map((e=>e.createdAt));(t.createdAtMath.max(...e)&&!this._hasNext)&&s.push(t)}}}else if(t instanceof _.SendableMessage){const e=Ve(this._unsentMessages,t);e>=0&&(n.push(t),this._unsentMessages[e]=t)}return d.shouldGiveEvent(t)&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,a;const r=new Ie(t);n.length>0?null===(e=this._handler)||void 0===e||e.onMessagesUpdated(r,this.channel,n):i.length>0?null===(a=this._handler)||void 0===a||a.onMessagesDeleted(r,this.channel,[],i):s.length>0&&this._addMessagesToView(s,t)})))),n}_removeMessagesFromView(e,t){const s=[],n=[];for(const t of e){const e=this._messages.findIndex((e=>e.messageId===t));if(e>=0){const t=this._messages[e];s.push(t.messageId),n.push(t),this._messages.splice(e,1)}}return d.shouldGiveEvent(t)&&n.length>0&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const i=new Ie(t);null===(e=this._handler)||void 0===e||e.onMessagesDeleted(i,this.channel,s,n)})))),s}_removeUnsentMessageFromView(e,t){const s=this._unsentMessages.findIndex((t=>t.reqId===e));s>=0&&this._unsentMessages.splice(s,1)}_getLocalMessages(e,{prevLimit:t=0,nextLimit:s=0,inclusive:n=!0}){return d.__awaiter(this,void 0,void 0,(function*(){const i=Ae.of(this._iid);let a=[];n&&(a=yield i._getExactlyMatchingMessagesForTokenFromCache(this._channel.url,e,this.filter));const r=t>0?yield i.getMessagesFromCache(this._channel.url,e,"prev",this.filter,t,!1):[],o=s>0?yield i.getMessagesFromCache(this._channel.url,e,"next",this.filter,s,!1):[];return[...a,...r,...o].sort(((e,t)=>t.createdAt-e.createdAt))}))}_getRemoteMessages(e,{prevLimit:t=0,nextLimit:s=0,source:n=d.MessageEventSource.REQUEST_MESSAGE,reverse:i=!1,checkingContinuousMessages:a=!1}){return d.__awaiter(this,void 0,void 0,(function*(){const r=_.MessageManager.of(this._iid);return t>0||s>0?yield r._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,e,d.undefineNullProps(Object.assign(Object.assign({},this.filter),{isInclusive:!0,reverse:i,prevResultSize:t,nextResultSize:s,includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0})),n,a):{messages:[],isContinuousMessages:!1}}))}_checkHugeGap(){var e;return d.__awaiter(this,void 0,void 0,(function*(){if(this._messages.length>0){const e=this._syncRange.top,t=this.viewTop,s=this._syncRange.bottom,n=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,i=Ae.of(this._iid),a=yield i.getCachedMessageCountBetween(this._channel.url,this.filter,t,e),r=yield i.getCachedMessageCountBetween(this._channel.url,this.filter,s,n);yield d.asyncRetry((()=>d.__awaiter(this,void 0,void 0,(function*(){var i;const{dispatcher:o,requestQueue:l,cacheContext:h}=d.Vault.of(this._iid),u=new Fe(Object.assign({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:t,prevEnd:e,prevCount:a,nextStart:s,nextEnd:n,nextCount:r,checkingContinuousMessages:h.localCacheEnabled},this.filter)),c=yield l.send(u),{isHugeGap:_,prevMessages:p=[],prevHasMore:m,isContinuousPrevMessages:g,nextMessages:C=[],nextHasmore:v,isContinuousNextMessages:E}=c.as(ke);if(_)d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;null===(e=this._handler)||void 0===e||e.onHugeGapDetected()}))));else{const e=this.viewTop,t=this.viewBottom,s=Math.min(Number.MAX_SAFE_INTEGER,e,...p.map((e=>e.createdAt))),n=Math.max(0,t,...C.map((e=>e.createdAt)));o.dispatch(new d.MessageUpdateEventCommand({messages:p,source:d.MessageEventSource.SYNC_MESSAGE_FILL})),o.dispatch(new d.MessageUpdateEventCommand({messages:C,source:d.MessageEventSource.SYNC_MESSAGE_FILL})),this._syncRange.extends(s,n),(g||E)&&(null===(i=this._backgroundSync)||void 0===i||i.range.extends(s,n)),m&&this._prevFill.start(s),v&&this._nextFill.start(n)}}))),1)}else{const{cacheContext:t}=d.Vault.of(this._iid),s=Math.floor(this._limit/2),n=Date.now();try{const{messages:i,isContinuousMessages:a}=yield this._getRemoteMessages(n,{prevLimit:s,nextLimit:s,source:d.MessageEventSource.SYNC_MESSAGE_FILL,checkingContinuousMessages:t.localCacheEnabled});if(i.length>0){const t=i.map((e=>e.createdAt));let r=0,o=0;for(let e=0;e=n&&o++}this._hasPrevious=r>=s,this._hasNext=o>=s,this._syncRange.extends(...t),a&&(null===(e=this._backgroundSync)||void 0===e||e.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(i,d.MessageEventSource.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1}catch(e){e instanceof d.SendbirdError&&e.code===d.SendbirdErrorCode.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1)}}}))}_loadUnsentMessages(){return d.__awaiter(this,void 0,void 0,(function*(){const e=Ae.of(this._iid);this._unsentMessages=yield e.getUnsentMessagesFromCache(this._channel.url,this.filter)}))}_hasPollMessage(){return d.__awaiter(this,void 0,void 0,(function*(){const e=Ae.of(this._iid);return(yield e.getPollMessagesFromCache(this._channel.url,Date.now()+Be,this.filter,1)).length>0}))}_refreshChannel(e){Ae.of(this._iid).refreshChannel(this.channel.url,!0,e)}_startCheckMyMutedTimer(e){this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;this._checkMyMutedStateTimer=void 0;let t=!0;try{t=!(yield this._channel.getMyMutedInfo()).isMuted}catch(e){t=!0}finally{if(t){this.channel.myMutedState=exports.MutedState.UNMUTED;const t=new Ne(u.GroupChannelEventSource.EVENT_CHANNEL_UNMUTED);null===(e=this._handler)||void 0===e||e.onChannelUpdated(t,this.channel)}}}))),e+1e3)}_clearCheckMyMutedTimer(){this._checkMyMutedStateTimer&&(clearTimeout(this._checkMyMutedStateTimer),this._checkMyMutedStateTimer=void 0)}initialize(e){const t=new We;this._messages=[],this._unsentMessages=[],this._syncRange=new ye({}),this._hasNext=!0,this._hasPrevious=!0,this._refreshChannel(u.GroupChannelEventSource.REFRESH_CHANNEL),d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){const e=yield this.channel.getMyMutedInfo();e.isMuted&&-1!==e.remainingDuration&&this._startCheckMyMutedTimer(e.remainingDuration)}))));const s=Math.floor(this._limit/2);if(e===exports.MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:s,nextLimit:s}).then((e=>d.__awaiter(this,void 0,void 0,(function*(){const s=this._filterUnderOffsetMessage(e);this._addMessagesToView(s,d.MessageEventSource.REQUEST_MESSAGE),yield this._loadUnsentMessages(),t._invokeResponse("local",null,s)})))).catch((e=>{if(d.isThrowingOutside(e))throw e;t._invokeResponse("local",e,null)})).finally((()=>{const{cacheContext:e}=d.Vault.of(this._iid);this._getRemoteMessages(this._startingPoint,{prevLimit:s,nextLimit:s,reverse:!0,checkingContinuousMessages:e.localCacheEnabled}).then((({messages:e,isContinuousMessages:n})=>{var i;this._messages=[];const a=this._filterUnderOffsetMessage(e);if(a.length>0){const e=a.map((e=>e.createdAt));let t=0,r=0;for(let s=0;sthis._startingPoint&&r++}this._hasPrevious=t>=s,this._hasNext=r>=s,this._syncRange.extends(...a.map((e=>e.createdAt))),n&&(null===(i=this._backgroundSync)||void 0===i||i.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(a,d.MessageEventSource.REQUEST_MESSAGE)}else this._hasPrevious=!1,this._hasNext=!1;t._invokeResponse("remote",null,a)})).catch((e=>{if(d.isThrowingOutside(e))throw e;t._invokeResponse("remote",e,null)}))}));const{cacheContext:n,statLogCollector:i}=d.Vault.of(this._iid);return i.put(new d.DailyRecordStatLog({type:d.StatType.FEATURE_LOCALCACHE,data:{use_local_cache:n.localCacheEnabled,collection_interface:{message_init_policy:e}}})),t}loadPrevious(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._isDisposed)throw new d.SendbirdError({code:d.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});if(!this._hasPrevious)return[];const e=Math.floor(this._limit/2),t=this.viewTop;let s=[];return yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){s=this._filterUnderOffsetMessage(yield this._getLocalMessages(t,{prevLimit:e,inclusive:!1}))})))),s.lengthd.__awaiter(this,void 0,void 0,(function*(){var n,i;const{cacheContext:a}=d.Vault.of(this._iid),r=yield this._getRemoteMessages(t,{prevLimit:e,reverse:!0,checkingContinuousMessages:a.localCacheEnabled});s=this._filterUnderOffsetMessage(r.messages),s=s.filter((e=>Ve(this._messages,e)<0)),this._hasPrevious=s.length>=e,s.length>0&&(this._syncRange.extends(...s.map((e=>e.createdAt))),(null===(n=this._backgroundSync)||void 0===n?void 0:n.range.overlap(this._syncRange))&&r.isContinuousMessages&&(null===(i=this._backgroundSync)||void 0===i||i.range.extends(this._syncRange.top)))})))),this._addMessagesToView(s,d.MessageEventSource.REQUEST_MESSAGE)):(this._hasPrevious=s.length>=e,s.length>0&&this._addMessagesToView(s,d.MessageEventSource.REQUEST_MESSAGE)),s}))}loadNext(){var e;return d.__awaiter(this,void 0,void 0,(function*(){if(this._isDisposed)throw new d.SendbirdError({code:d.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});if(!this._hasNext)return[];const t=Math.floor(this._limit/2),s=this.viewBottom;let n=[];return yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){n=this._filterUnderOffsetMessage(yield this._getLocalMessages(s,{nextLimit:t,inclusive:!1}))})))),n.lengthd.__awaiter(this,void 0,void 0,(function*(){var e,i;const{cacheContext:a}=d.Vault.of(this._iid),r=yield this._getRemoteMessages(s,{nextLimit:t,reverse:!0,checkingContinuousMessages:a.localCacheEnabled});n=this._filterUnderOffsetMessage(r.messages),n=n.filter((e=>Ve(this._messages,e)<0)),this._hasNext=n.length>=t,n.length>0&&(this._syncRange.extends(...n.map((e=>e.createdAt))),(null===(e=this._backgroundSync)||void 0===e?void 0:e.range.overlap(this._syncRange))&&r.isContinuousMessages&&(null===(i=this._backgroundSync)||void 0===i||i.range.extends(this._syncRange.bottom)))})))),this._addMessagesToView(n,d.MessageEventSource.REQUEST_MESSAGE)):(this._hasNext=n.length>=t,n.length>0&&this._addMessagesToView(n,d.MessageEventSource.REQUEST_MESSAGE)),n}))}removeFailedMessage(e){return d.__awaiter(this,void 0,void 0,(function*(){if(this._isDisposed)throw new d.SendbirdError({code:d.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});const t=Ae.of(this._iid);yield t.removeFailedMessageFromCache(e);const s=this._unsentMessages.findIndex((t=>t.reqId===e));s>-1&&this._unsentMessages.splice(s,1)}))}dispose(){var e,t,s;if(this._isDisposed)return;this._isDisposed=!0;const{cacheContext:n,dispatcher:i}=d.Vault.of(this._iid);this._messages=[],this._clearCheckMyMutedTimer(),this._channel._updateMessageCollectionLastAccessedAt(),i.dispatch(new u.GroupChannelUpdateEventCommand({channels:[this._channel],source:u.GroupChannelEventSource.CHANNEL_LASTACCESSEDAT_UPDATED})),n.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===(s=this._pollChangelogSync)||void 0===s||s.close();const a=Ae.of(this._iid);a.unsubscribeGroupChannelEvent(this._key),a.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}}const ze={coverUrl:void 0,coverImage:void 0,isDistinct:void 0,isPublic:void 0,isDiscoverable:void 0,accessCode:void 0,name:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,messageSurvivalSeconds:void 0};class Qe extends d.APIRequestCommand{constructor(e){const{channelUrl:t,token:s,limit:n,order:i,mutedMemberFilter:a,memberStateFilter:r,nicknameStartsWithFilter:o,operatorFilter:l}=e;super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/members`,this.params={token:s,limit:n,order:i,muted_member_filter:a,member_state_filter:r,nickname_startswith:o,operator_filter:l,show_member_is_muted:!0,show_read_receipt:!0,show_delivery_receipt:!0}}}class Ke extends d.APIResponseCommand{constructor(e,t){super(e,t),this.members=[];const{next:s,members:n}=t;this.token=s,n&&n.length>0&&(this.members=n.map((t=>new m(e,t))))}}var Ye,Je,Xe;exports.MutedMemberFilter=void 0,(Ye=exports.MutedMemberFilter||(exports.MutedMemberFilter={})).ALL="all",Ye.MUTED="muted",Ye.UNMUTED="unmuted",exports.MemberListOrder=void 0,(Je=exports.MemberListOrder||(exports.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",Je.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",exports.MemberStateFilter=void 0,(Xe=exports.MemberStateFilter||(exports.MemberStateFilter={})).ALL="all",Xe.JOINED="joined_only",Xe.INVITED="invited_only",Xe.INVITED_BY_FRIEND="invited_by_friend",Xe.INVITED_BY_NON_FRIEND="invited_by_non_friend";class Ze extends d.ChannelDataListQuery{constructor(e,t,s){var n,i,a,r;super(e,t,d.ChannelType.GROUP,s),this.mutedMemberFilter=exports.MutedMemberFilter.ALL,this.memberStateFilter=exports.MemberStateFilter.ALL,this.nicknameStartsWithFilter=null,this.operatorFilter=exports.OperatorFilter.ALL,this.order=exports.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL,this.mutedMemberFilter=null!==(n=s.mutedMemberFilter)&&void 0!==n?n:exports.MutedMemberFilter.ALL,this.memberStateFilter=null!==(i=s.memberStateFilter)&&void 0!==i?i:exports.MemberStateFilter.ALL,this.nicknameStartsWithFilter=null!==(a=s.nicknameStartsWithFilter)&&void 0!==a?a:null,this.order=null!==(r=s.order)&&void 0!==r?r:exports.MemberListOrder.MEMBER_NICKNAME_ALPHABETICAL}_validate(){return super._validate()&&d.isEnumOf(exports.MutedMemberFilter,this.mutedMemberFilter)&&d.isEnumOf(exports.MemberStateFilter,this.memberStateFilter)&&(d.isTypeOf("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&d.isEnumOf(exports.OperatorFilter,this.operatorFilter)&&d.isEnumOf(exports.MemberListOrder,this.order)}next(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw d.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=d.Vault.of(this._iid),t=new Qe(d.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),s=yield e.send(t),{members:n,token:i}=s.as(Ke);return this._token=i,this._hasNext=!!i,this._isLoading=!1,n}return[]}throw d.SendbirdError.invalidParameters}))}}class et extends d.APIRequestCommand{constructor(e){const{channelUrl:t,userId:s,accessCode:n}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/accept`,this.params={user_id:s,access_code:n}}}class tt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new Ot(e,t),this.channel.myMemberState=exports.MemberState.JOINED}}class st extends d.APIRequestCommand{constructor(e){const{channelUrl:t,isDistinct:s,isPublic:n,isDiscoverable:i,coverUrl:a,coverImage:r,accessCode:o,name:l,data:h,customType:u,operatorUserIds:c,messageSurvivalSeconds:_}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}`,this.params=d.deundefined({is_distinct:s,is_public:n,is_discoverable:i,name:l,data:h,custom_type:u,cover_url:a,cover_file:r,access_code:o,operator_ids:c,message_survival_seconds:_})}}class nt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channel=new Ot(e,t)}}class it extends d.APIRequestCommand{constructor(e){const{channelUrl:t}=e;super(),this.method=d.APIRequestMethod.DELETE,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}`}}class at extends d.APIRequestCommand{constructor(e){const{channelUrl:t}=e;super(),this.method=d.APIRequestMethod.DELETE,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/hide`}}class rt extends d.APIRequestCommand{constructor({userId:e,channelUrl:t,countPreference:s}){super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/count_preference/${encodeURIComponent(t)}`,this.params={count_preference:s}}}class ot extends d.APIResponseCommand{constructor(e,t){super(e,t),this.countPreference=t.count_preference}}class lt extends d.APIRequestCommand{constructor(e){const{channelUrl:t}=e;super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(t)}/reset_user_history`}}class dt extends d.APIResponseCommand{constructor(e,t){super(e,t);const{ts_message_offset:s}=t;this.messageOffsetTimestamp=s}}const ht=Object.assign(Object.assign({},h.BaseMessageUpdateParamsDefault),{scheduledAt:void 0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),ut=Object.assign(Object.assign({},h.UserMessageUpdateParamsDefault),{scheduledAt:void 0});class ct extends d.APIRequestCommand{constructor(e){var t;super();let s=[];e.mentionType===d.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId))));const{channelType:n,channelUrl:i,scheduledMessageId:a}=e;this.method=d.APIRequestMethod.PUT,this.path=`${d.getChannelApiPathByType(n)}/${encodeURIComponent(i)}/scheduled_messages/${encodeURIComponent(a)}`,this.params=d.deundefined(d.undefineNullProps({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:d.ServerSideMessageType.FILE,url:e.fileUrl,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,thumbnails:e.thumbnailSizes?e.thumbnailSizes.map((e=>_.Thumbnail.payloadify(e))):[],custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(t=e.metaArrays)||void 0===t?void 0:t.map((e=>_.MessageMetaArray.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?_.AppleCriticalAlertOptions.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption}))}}class _t extends d.APIResponseCommand{constructor(e,t){super(e,t),this.message=new _.FileMessage(e,t)}}class pt extends d.APIRequestCommand{constructor(e){var t;super();let s=[];e.mentionType===d.MentionType.USERS&&(e.mentionedUserIds?s=e.mentionedUserIds:e.mentionedUsers&&(s=e.mentionedUsers.map((e=>e.userId))));const{channelType:n,channelUrl:i,scheduledMessageId:a}=e;this.method=d.APIRequestMethod.PUT,this.path=`${d.getChannelApiPathByType(n)}/${encodeURIComponent(i)}/scheduled_messages/${encodeURIComponent(a)}`,this.params=d.deundefined(d.undefineNullProps({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:d.ServerSideMessageType.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:s,sorted_metaarray:null===(t=e.metaArrays)||void 0===t?void 0:t.map((e=>_.MessageMetaArray.payloadify(e))),apple_critical_alert_options:e.appleCriticalAlertOptions?_.AppleCriticalAlertOptions.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption}))}}class mt extends d.APIRequestCommand{constructor(e){super();const{channelType:t,channelUrl:s,scheduledMessageId:n}=e;this.method=d.APIRequestMethod.DELETE,this.path=`${d.getChannelApiPathByType(t)}/${encodeURIComponent(s)}/scheduled_messages/${encodeURIComponent(n)}`}}class gt extends d.APIRequestCommand{constructor(e){super();const{channelType:t,channelUrl:s,scheduledMessageId:n}=e;this.method=d.APIRequestMethod.POST,this.path=`${d.getChannelApiPathByType(t)}/${encodeURIComponent(s)}/scheduled_messages/${encodeURIComponent(n)}/send_now`}}class Ct extends d.APIRequestCommand{constructor({userId:e,channelUrl:t,pushTriggerOption:s}){super(),this.method=d.APIRequestMethod.PUT,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/push_preference/${encodeURIComponent(t)}`,this.params={push_trigger_option:s}}}class vt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option,this.enabled=t.enable}}class Et extends d.APIRequestCommand{constructor({userId:e,channelUrl:t}){super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_USERS}/${encodeURIComponent(e)}/push_preference/${encodeURIComponent(t)}`}}class ft extends d.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option,this.enabled=t.enable}}class Mt extends d.APIRequestCommand{constructor({channelType:e,channelUrl:t,messageId:s}){super(),this.method=d.APIRequestMethod.POST,this.path=`${d.getChannelApiPathByType(e)}/${encodeURIComponent(t)}/messages/${s}/pin`}}class yt extends d.APIRequestCommand{constructor({channelType:e,channelUrl:t,messageId:s}){super(),this.method=d.APIRequestMethod.DELETE,this.path=`${d.getChannelApiPathByType(e)}/${encodeURIComponent(t)}/messages/${s}/pin`}}class St extends d.InstancedObject{constructor(e,t){super(e),this.message=_.parseMessagePayload(e,t.message)}}class bt extends d.APIRequestCommand{constructor(e){const{channelType:t,channelUrl:s,limit:n,token:i,includeReactions:a,includeMetaArray:r,includeParentMessageInfo:o,includeThreadInfo:l,includePollDetails:h}=e;super(),this.method=d.APIRequestMethod.GET,this.path=`${d.getChannelApiPathByType(t)}/${encodeURIComponent(s)}/pinned_messages`,this.params=d.deundefined({limit:n,token:i,include_reactions:a,with_sorted_meta_array:r,include_thread_info:l,include_parent_message_info:o,include_poll_details:h})}}class At extends d.APIResponseCommand{constructor(e,t){super(e,t);const{pinned_messages:s,has_more:n,next:i}=t;this.pinnedMessages=s.map((t=>new St(e,t))),this.hasMore=n,this.token=i}}class Ut extends d.ChannelDataListQuery{constructor(e,t,s,n){super(e,t,s,n),this.includeMetaArray=n.includeMetaArray,this.includeReactions=n.includeReactions,this.includeParentMessageInfo=n.includeParentMessageInfo,this.includeThreadInfo=n.includeThreadInfo,this.includePollDetails=n.includePollDetails}_validate(){return super._validate()&&d.isTypeOf("boolean",this.includeMetaArray,!0)&&d.isTypeOf("boolean",this.includeReactions,!0)&&d.isTypeOf("boolean",this.includeParentMessageInfo,!0)&&d.isTypeOf("boolean",this.includeThreadInfo,!0)&&d.isTypeOf("boolean",this.includePollDetails,!0)}next(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw d.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=d.Vault.of(this._iid),t=new bt(Object.assign(Object.assign({},this),{token:this._token})),s=yield e.send(t),{pinnedMessages:n,hasMore:i,token:a}=s.as(At);return this._token=a,this._hasNext=!!i,this._isLoading=!1,n}return[]}throw d.SendbirdError.invalidParameters}))}}var Tt,Nt,It;exports.CountPreference=void 0,(Tt=exports.CountPreference||(exports.CountPreference={})).ALL="all",Tt.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",Tt.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",Tt.OFF="off",exports.MutedState=void 0,(Nt=exports.MutedState||(exports.MutedState={})).MUTED="muted",Nt.UNMUTED="unmuted",exports.HiddenState=void 0,(It=exports.HiddenState||(exports.HiddenState={})).UNHIDDEN="unhidden",It.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",It.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";class Ot extends h.BaseChannel{constructor(e,t){var s,n,i,a,r,o,l,h,u,c,p,g,C,v,E,f,M,y;super(e,t),this._unreadMemberStateMap=new Map,this._undeliveredMemberStateMap=new Map,this._typingStatus=new Map,this._lastMemberCountUpdated=0,this._typingStarted=0,this._typingEnded=0,this.isDistinct=!1,this.isSuper=!1,this.isBroadcast=!1,this.isExclusive=!1,this.isPublic=!1,this.isDiscoverable=!0,this.isAccessCodeRequired=!1,this.isPushEnabled=!1,this.unreadMessageCount=0,this.unreadMentionCount=0,this.members=[],this.memberCount=0,this.joinedMemberCount=0,this.hiddenState=exports.HiddenState.UNHIDDEN,this.lastMessage=null,this.messageOffsetTimestamp=0,this.messageSurvivalSeconds=-1,this.myMemberState=exports.MemberState.NONE,this.myRole=d.Role.NONE,this.myMutedState=exports.MutedState.UNMUTED,this.myLastRead=0,this.myCountPreference=exports.CountPreference.ALL,this.myPushTriggerOption=d.PushTriggerOption.DEFAULT,this.inviter=null,this.invitedAt=0,this.joinedAt=0,this.pinnedMessageIds=[],this.lastPinnedMessage=null,this._pinnedMessagesUpdatedAt=0,this._myMutedRemainingTime=-1,this.channelType=d.ChannelType.GROUP,this.isDistinct=null!==(s=t.is_distinct)&&void 0!==s&&s,this.isSuper=null!==(n=t.is_super)&&void 0!==n&&n,this.isBroadcast=null!==(i=t.is_broadcast)&&void 0!==i&&i,this.isExclusive=null!==(a=t.is_exclusive)&&void 0!==a&&a,this.isPublic=null!==(r=t.is_public)&&void 0!==r&&r,this.isDiscoverable=null!==(o=t.is_discoverable)&&void 0!==o?o:this.isPublic,this.isAccessCodeRequired=null!==(l=t.is_access_code_required)&&void 0!==l&&l,this.isPushEnabled=null!==(h=t.is_push_enabled)&&void 0!==h&&h,Array.isArray(t.members)&&this.members.push(...t.members.map((e=>new m(this._iid,e)))),this.memberCount=null!==(u=t.member_count)&&void 0!==u?u:0,this.joinedMemberCount=null!==(c=t.joined_member_count)&&void 0!==c?c:0,this.hiddenState=d.isEnumOf(exports.HiddenState,t.hidden_state)?t.hidden_state:exports.HiddenState.UNHIDDEN,this.messageOffsetTimestamp=null!==(p=t.ts_message_offset)&&void 0!==p?p:0,this.messageSurvivalSeconds=null!==(g=t.message_survival_seconds)&&void 0!==g?g:-1,this.lastMessage=t.last_message?_.parseMessagePayload(this._iid,Object.assign({channel_type:this.channelType},t.last_message)):null,t.read_receipt&&Object.keys(t.read_receipt).forEach((e=>{d.isTypeOf("number",t.read_receipt[e])&&this._updateUnreadMemberState(e,t.read_receipt[e])})),t.delivery_receipt&&Object.keys(t.delivery_receipt).forEach((e=>{d.isTypeOf("number",t.delivery_receipt[e])&&this._updateUndeliveredMemberState(e,t.delivery_receipt[e])})),this.myMemberState=d.isEnumOf(exports.MemberState,t.member_state)?t.member_state:exports.MemberState.NONE,this.myRole=d.isEnumOf(d.Role,t.my_role)?t.my_role:d.Role.NONE,d.isEnumOf(exports.MutedState,t.is_muted)?this.myMutedState=t.is_muted:d.isTypeOf("boolean",t.is_muted)?this.myMutedState=t.is_muted?exports.MutedState.MUTED:exports.MutedState.UNMUTED:this.myMutedState=exports.MutedState.UNMUTED,this.myCountPreference=d.isEnumOf(exports.CountPreference,t.count_preference)?t.count_preference:exports.CountPreference.ALL,this.myPushTriggerOption=d.isEnumOf(d.PushTriggerOption,t.push_trigger_option)?t.push_trigger_option:d.PushTriggerOption.ALL,this.myLastRead=null!==(C=t.user_last_read)&&void 0!==C?C:0,this.inviter=t.inviter?new d.User(this._iid,t.inviter):null,this.invitedAt=null!==(v=t.invited_at)&&void 0!==v?v:0,this.joinedAt=null!==(E=t.joined_ts)&&void 0!==E?E:0,this._updateUnreadCount(null!==(f=t.unread_message_count)&&void 0!==f?f:0,null!==(M=t.unread_mention_count)&&void 0!==M?M:0),this.pinnedMessageIds=null!==(y=t.pinned_message_ids)&&void 0!==y?y:[],this.lastPinnedMessage=t.latest_pinned_message?_.parseMessagePayload(this._iid,Object.assign({channel_type:this.channelType},t.latest_pinned_message)):null}get isHidden(){return this.hiddenState!==exports.HiddenState.UNHIDDEN}get isTyping(){return this._typingStatus.size>0}get cachedUnreadMemberState(){const e={};for(const[t,s]of this._unreadMemberStateMap)e[t]=s;return e}get cachedUndeliveredMemberState(){const e={};for(const[t,s]of this._undeliveredMemberStateMap)e[t]=s;return e}static payloadify(e){return d.deundefined(d.undefineNullProps(Object.assign(Object.assign({},super.payloadify(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((e=>m.payloadify(e))),last_message:e.lastMessage?_.payloadifyMessage(e.lastMessage):null,inviter:e.inviter?d.User.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,pinned_message_ids:e.pinnedMessageIds,latest_pinned_message:e.lastPinnedMessage?_.payloadifyMessage(e.lastPinnedMessage):null})))}_shouldUpdateLastMessageWith(e){return!(e instanceof _.SendableMessage&&e.parentMessageId>0&&!e.replyToChannel)&&(!this.lastMessage||this.lastMessage.createdAt=0)if(this.myCountPreference===exports.CountPreference.ALL||this.myCountPreference===exports.CountPreference.UNREAD_MESSAGE_COUNT_ONLY)if(this.isExclusive||this.isSuper||this.isBroadcast){const{maxSuperGroupChannelUnreadCount:t}=d.Vault.of(this._iid);this.unreadMessageCount=t&&e>=t?t:e}else this.unreadMessageCount=e;else this.unreadMessageCount=0;else this.unreadMessageCount=0;"number"==typeof t&&t>=0&&(this.myCountPreference===exports.CountPreference.ALL||this.myCountPreference===exports.CountPreference.UNREAD_MENTION_COUNT_ONLY)?this.unreadMentionCount=t:this.unreadMentionCount=0}_updateUnreadMemberState(e,t){const s=this._unreadMemberStateMap.get(e);if(!s||s0?this._typingStatus.set(e.userId,{user:e,ts:t}):this._typingStatus.delete(e.userId)}_clearTypingStatus(){this._typingStatus.clear(),this._typingStarted=0,this._typingEnded=0}_setLatestMemberCount(e,t,s){let n=!1;return s>=this._lastMemberCountUpdated&&(this._lastMemberCountUpdated=s,n=e!==this.memberCount||t!==this.joinedMemberCount,this.memberCount=e,this.joinedMemberCount=t),n}isReadMessage(e){const{sdkState:t}=d.Vault.of(this._iid),s=this._unreadMemberStateMap.get(t.userId);return!!s&&s>=e.createdAt}serialize(){return d.serialize(this,(e=>{e.cachedUnreadMemberState=this.cachedUnreadMemberState,e.cachedUndeliveredMemberState=this.cachedUndeliveredMemberState}))}createMessageCollection(e={}){return new $e(this._iid,Object.assign({channel:this},e))}createMemberListQuery(e={}){return new Ze(this._iid,this.url,e)}createPinnedMessageListQuery(e={}){return new Ut(this._iid,this.url,this.channelType,e)}addMember(e,t=0){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){const s=this.members.findIndex((t=>t.userId===e.userId));if(s>-1){const t=this.members[s];t.state===exports.MemberState.JOINED&&(e.state=t.state),this.members.splice(s,1),this.memberCount--}this.members.push(e),this.memberCount++,this._updateUnreadMemberState(e.userId,t),this._updateUndeliveredMemberState(e.userId,t)}}removeMember(e){if(!this.isExclusive&&!this.isSuper&&!this.isBroadcast){const t=e instanceof m?e.userId:e,s=this.members.findIndex((e=>e.userId===t));if(s>-1)return this.members.splice(s,1),this.memberCount--,!0}return!1}getUnreadMemberCount(e){if(e instanceof _.SendableMessage&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){const{sdkState:t}=d.Vault.of(this._iid),s=e.createdAt;let n=0;for(const i of this.members)if(t.userId!==i.userId&&i.state===exports.MemberState.JOINED&&e.sender.userId!==i.userId){(this.cachedUnreadMemberState[i.userId]||0){if(t||a.userId!==s.userId&&a.userId!==(null==n?void 0:n.userId)){const t=this._unreadMemberStateMap.get(a.userId);t&&t>=e.createdAt&&i.push(a)}})),i}getUnreadMembers(e,t=!1){const{sdkState:s}=d.Vault.of(this._iid);if(!s.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];const n=e instanceof _.SendableMessage?e.sender:null,i=[];return this.members.forEach((a=>{if(t||a.userId!==s.userId&&a.userId!==(null==n?void 0:n.userId)){const t=this._unreadMemberStateMap.get(a.userId);t&&t{if(e||n.userId!==t.userId){const e=this._unreadMemberStateMap.get(n.userId);s[n.userId]=new g(this._iid,{channel_url:this.url,channel_type:this.channelType,user:m.payloadify(n),ts:null!=e?e:0})}})),s}getTypingUsers(){const e=[];return this._typingStatus.forEach((t=>{const{user:s}=t;e.push(s)})),e}invalidateTypingStatus(){const{typingIndicatorInvalidateTime:e}=d.Vault.of(this._iid),t=Date.now();let s=!1;return this._typingStatus.forEach(((n,i)=>{const{ts:a}=n;t-a>=e&&(this._typingStatus.delete(i),s=!0)})),s}refresh(){return d.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:e,dispatcher:t}=d.Vault.of(this._iid),s=new x({channelUrl:this.url}),n=yield e.send(s),{channel:i}=n.as(R);return this._update(i),t.dispatch(new u.GroupChannelUpdateEventCommand({channels:[i],source:u.GroupChannelEventSource.REQUEST_CHANNEL})),this}))}freeze(){const e=Object.create(null,{freeze:{get:()=>super.freeze}});return d.__awaiter(this,void 0,void 0,(function*(){yield e.freeze.call(this);const{dispatcher:t}=d.Vault.of(this._iid);t.dispatch(new u.GroupChannelUpdateEventCommand({channels:[this],source:u.GroupChannelEventSource.EVENT_CHANNEL_FROZEN,isWebSocketEventComing:!0}))}))}unfreeze(){const e=Object.create(null,{unfreeze:{get:()=>super.unfreeze}});return d.__awaiter(this,void 0,void 0,(function*(){yield e.unfreeze.call(this);const{dispatcher:t}=d.Vault.of(this._iid);t.dispatch(new u.GroupChannelUpdateEventCommand({channels:[this],source:u.GroupChannelEventSource.EVENT_CHANNEL_UNFROZEN,isWebSocketEventComing:!0}))}))}updateChannel(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},ze),e);d.unless((e=>d.isTypeOf("string",e.coverUrl,!0)&&(d.isFile(e.coverImage)||d.isTypeOf("string",e.coverImage,!0))&&d.isTypeOf("boolean",e.isDistinct,!0)&&d.isTypeOf("boolean",e.isPublic,!0)&&d.isTypeOf("boolean",e.isDiscoverable,!0)&&d.isTypeOf("string",e.accessCode,!0)&&d.isTypeOf("string",e.name,!0)&&d.isTypeOf("string",e.data,!0)&&d.isTypeOf("string",e.customType,!0)&&d.isArrayOf("string",e.operatorUserIds,!0)&&d.isTypeOf("number",e.messageSurvivalSeconds,!0))(t)).throw(d.SendbirdError.invalidParameters);const{dispatcher:s,requestQueue:n}=d.Vault.of(this._iid),i=new st(Object.assign({channelUrl:this.url},t)),a=yield n.send(i),{channel:r}=a.as(nt);return this._update(r),s.dispatch(new u.GroupChannelUpdateEventCommand({channels:[r],source:u.GroupChannelEventSource.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),this}))}invite(e){return d.__awaiter(this,void 0,void 0,(function*(){return d.unless(e.every((e=>e instanceof d.User))).throw(d.SendbirdError.invalidParameters),this.inviteWithUserIds(e.map((e=>e.userId)))}))}inviteWithUserIds(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isArrayOf("string",e)).throw(d.SendbirdError.invalidParameters);const{dispatcher:t,requestQueue:s}=d.Vault.of(this._iid),n=new ne({channelUrl:this.url,userIds:e}),i=yield s.send(n),{channel:a}=i.as(ie);return this._update(a),t.dispatch(new u.GroupChannelUpdateEventCommand({channels:[a],source:u.GroupChannelEventSource.EVENT_CHANNEL_INVITED,isWebSocketEventComing:!0})),this}))}join(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isTypeOf("string",e,!0)).throw(d.SendbirdError.invalidParameters);const{dispatcher:t,sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new X({channelUrl:this.url,userId:s.userId,accessCode:e}),a=yield n.send(i),{channel:r}=a.as(Z);return r.myMemberState=this.myMemberState=exports.MemberState.JOINED,this._update(r),t.dispatch(new u.GroupChannelUpdateEventCommand({channels:[r],source:u.GroupChannelEventSource.EVENT_CHANNEL_JOINED,isWebSocketEventComing:!0})),this}))}leave(e=!1){return d.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=d.Vault.of(this._iid),n=new te({channelUrl:this.url,userId:t.userId,shouldRemoveOperatorStatus:e});yield s.send(n),this.myMemberState=exports.MemberState.NONE}))}acceptInvitation(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isTypeOf("string",e,!0)).throw(d.SendbirdError.invalidParameters);const{dispatcher:t,sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new et({channelUrl:this.url,userId:s.userId,accessCode:e}),a=yield n.send(i),{channel:r}=a.as(tt);return r.myMemberState=this.myMemberState=exports.MemberState.JOINED,this._update(r),t.dispatch(new u.GroupChannelUpdateEventCommand({channels:[r],source:u.GroupChannelEventSource.EVENT_CHANNEL_ACCEPTED_INVITE,isWebSocketEventComing:!0})),this}))}declineInvitation(){return d.__awaiter(this,void 0,void 0,(function*(){const{sdkState:e,requestQueue:t}=d.Vault.of(this._iid),s=new re({channelUrl:this.url,userId:e.userId});return yield t.send(s),this.myMemberState=exports.MemberState.NONE,this}))}sendUserMessage(e){const t=new _.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=u.AutoResendManager.of(this._iid);return super.sendUserMessage(e).onPending((e=>{n.completeCurrentAndProcessNextAutoResend(e),t._trigger(e)})).onFailed(((e,s)=>{s&&n.completeCurrentAndProcessNextAutoResend(s),t._triggerFailed(e,s)})).onSucceeded((e=>{this.hiddenState===exports.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE&&(this.hiddenState=exports.HiddenState.UNHIDDEN),n.completeCurrentAndProcessNextAutoResend(e),this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e);Ae.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new u.GroupChannelUpdateEventCommand({channels:[this],source:u.GroupChannelEventSource.EVENT_MESSAGE_SENT})),t._trigger(e)})),t}updateUserMessage(e,t){const s=Object.create(null,{updateUserMessage:{get:()=>super.updateUserMessage}});return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:n}=d.Vault.of(this._iid),i=yield s.updateUserMessage.call(this,e,t);let a=!1;!i.silent&&this._shouldUpdateLastMessageWith(i)&&(this.lastMessage=i,a=!0);let r=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===i.messageId&&(this.lastPinnedMessage=i,a=!0,r=!0),a){Ae.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),n.dispatch(new u.GroupChannelUpdateEventCommand({channels:[this],source:r?u.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED:u.GroupChannelEventSource.EVENT_MESSAGE_UPDATED}))}if(r){Ae.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return n.dispatch(new d.MessageUpdateEventCommand({messages:[i],source:d.MessageEventSource.EVENT_MESSAGE_UPDATED})),i}))}_autoResendUserMessage(e){const t=new _.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=u.AutoResendManager.of(this._iid);return super._autoResendUserMessage(e).onPending((e=>{n.completeCurrentAndProcessNextAutoResend(e),t._trigger(e)})).onFailed(((e,s)=>{n.completeCurrentAndProcessNextAutoResend(s),t._triggerFailed(e,s)})).onSucceeded((e=>{const i=Ae.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new u.GroupChannelUpdateEventCommand({channels:[this],source:u.GroupChannelEventSource.EVENT_MESSAGE_SENT})),t._trigger(e)})),t}sendFileMessage(e){const t=new _.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=u.AutoResendManager.of(this._iid);return super.sendFileMessage(e).onPending((e=>{n.completeCurrentAndProcessNextAutoResend(e),t._trigger(e)})).onFailed(((e,s)=>{s&&n.completeCurrentAndProcessNextAutoResend(s),t._triggerFailed(e,s)})).onSucceeded((e=>{const i=Ae.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new u.GroupChannelUpdateEventCommand({channels:[this],source:u.GroupChannelEventSource.EVENT_MESSAGE_SENT})),t._trigger(e)})),t}sendMultipleFilesMessage(e){const t=new _.MultipleFilesMessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid);return super.sendMultipleFilesMessage(e).onPending((e=>{t._trigger(e)})).onFailed(((e,s)=>{t._triggerFailed(e,s)})).onSucceeded((e=>{const n=Ae.of(this._iid);this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e),n.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new u.GroupChannelUpdateEventCommand({channels:[this],source:u.GroupChannelEventSource.EVENT_MESSAGE_SENT})),t._trigger(e)})).onFileUploaded(((e,s,n,i)=>{t._triggerOnFileUploaded(e,s,n,i)})),t}updateFileMessage(e,t){const s=Object.create(null,{updateFileMessage:{get:()=>super.updateFileMessage}});return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:n}=d.Vault.of(this._iid),i=yield s.updateFileMessage.call(this,e,t);let a=!1;!i.silent&&this._shouldUpdateLastMessageWith(i)&&(this.lastMessage=i,a=!0);let r=!1;if(this.lastPinnedMessage&&this.lastPinnedMessage.messageId===i.messageId&&(this.lastPinnedMessage=i,a=!0,r=!0),a){Ae.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),n.dispatch(new u.GroupChannelUpdateEventCommand({channels:[this],source:r?u.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED:u.GroupChannelEventSource.EVENT_MESSAGE_UPDATED}))}if(r){Ae.of(this._iid).handlers.map((e=>{e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(this)}))}return n.dispatch(new d.MessageUpdateEventCommand({messages:[i],source:d.MessageEventSource.EVENT_MESSAGE_UPDATED})),i}))}_autoResendFileMessage(e){const t=new _.MessageRequestHandler,{dispatcher:s}=d.Vault.of(this._iid),n=u.AutoResendManager.of(this._iid);return super._autoResendFileMessage(e).onPending((e=>{n.completeCurrentAndProcessNextAutoResend(e),t._trigger(e)})).onFailed(((e,s)=>{n.completeCurrentAndProcessNextAutoResend(s),t._triggerFailed(e,s)})).onSucceeded((e=>{const i=Ae.of(this._iid);n.completeCurrentAndProcessNextAutoResend(e),this._shouldUpdateLastMessageWith(e)&&(this.lastMessage=e),i.handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)})),s.dispatch(new u.GroupChannelUpdateEventCommand({channels:[this],source:u.GroupChannelEventSource.EVENT_MESSAGE_SENT})),t._trigger(e)})),t}deleteMessage(e){const t=Object.create(null,{deleteMessage:{get:()=>super.deleteMessage}});return d.__awaiter(this,void 0,void 0,(function*(){if(yield t.deleteMessage.call(this,e),0===e.messageId&&e instanceof _.SendableMessage){const{dispatcher:t}=d.Vault.of(this._iid);t.dispatch(new d.UnsentMessageRemoveEventCommand({reqId:e.reqId,source:d.MessageEventSource.EVENT_MESSAGE_DELETED}))}}))}hide(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},ce),e);d.unless((e=>d.isTypeOf("boolean",e.hidePreviousMessages,!0)&&d.isTypeOf("boolean",e.allowAutoUnhide,!0))(t)).throw(d.SendbirdError.invalidParameters);const{dispatcher:s,sdkState:n,requestQueue:i}=d.Vault.of(this._iid),a=new _e(Object.assign({channelUrl:this.url,userId:n.userId},t)),r=yield i.send(a),{messageOffsetTimestamp:o}=r.as(pe);return this.hiddenState=t.allowAutoUnhide?exports.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:exports.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE,t.hidePreviousMessages&&this._updateUnreadCount(0,0),o&&(this.messageOffsetTimestamp=o),s.dispatch(new u.GroupChannelUpdateEventCommand({channels:[this],source:u.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN,isWebSocketEventComing:!0})),this}))}unhide(){return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:e,requestQueue:t}=d.Vault.of(this._iid),s=new at({channelUrl:this.url});return yield t.send(s),this.hiddenState=exports.HiddenState.UNHIDDEN,e.dispatch(new u.GroupChannelUpdateEventCommand({channels:[this],source:u.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN,isWebSocketEventComing:!0})),this}))}delete(){return d.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:e}=d.Vault.of(this._iid),t=new it({channelUrl:this.url});yield e.send(t)}))}markAsRead(){return d.__awaiter(this,void 0,void 0,(function*(){const{sdkState:e,dispatcher:t,requestQueue:s}=d.Vault.of(this._iid),n=new le({channelUrl:this.url}),i=yield s.send(n),{readStatus:a}=i.as(de);if(this._updateUnreadMemberState(e.userId,a.readAt),this.unreadMessageCount>0||this.unreadMentionCount>0){this._updateUnreadCount(0,0);Ae.of(this._iid).handlers.map((e=>{e.onChannelChanged&&e.onChannelChanged(this)}))}t.dispatch(new u.GroupChannelUpdateEventCommand({channels:[this],source:u.GroupChannelEventSource.EVENT_CHANNEL_READ}))}))}markAsDelivered(){return d.__awaiter(this,void 0,void 0,(function*(){const{sdkState:e,requestQueue:t}=d.Vault.of(this._iid),s=new he({channelUrl:this.url,userId:e.userId});yield t.send(s)}))}startTyping(){return d.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:e,typingIndicatorThrottle:t}=d.Vault.of(this._iid),s=(new Date).getTime();if(s-this._typingStarted>=t){this._typingStarted=s,this._typingEnded=0;const t=new ge({channelUrl:this.url,time:this._typingStarted});e.send(t)}}))}endTyping(){return d.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:e,typingIndicatorThrottle:t}=d.Vault.of(this._iid),s=(new Date).getTime();if(s-this._typingEnded>=t){this._typingStarted=0,this._typingEnded=s;const t=new ve({channelUrl:this.url,time:this._typingStarted});e.send(t)}}))}createScheduledUserMessage(e){e=Object.assign(Object.assign({},u.ScheduledUserMessageCreateParamsDefault),e),d.unless(u.validateScheduledUserMessageCreateParams(e)).throw(d.SendbirdError.invalidParameters);const t=new _.MessageRequestHandler;return this._createScheduledUserMessage(e,t),t}updateScheduledUserMessage(e,t){return d.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},ut),t);d.unless((e=>h.validateUserMessageUpdateParams(e)&&d.isTypeOf("number",e.scheduledAt,!0))(s)).throw(d.SendbirdError.invalidParameters);const{requestQueue:n}=d.Vault.of(this._iid),i=new pt(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},s)),a=yield n.send(i),{message:r}=a.as(h.CreateScheduledUserMessageResponseCommand);return r}))}createScheduledFileMessage(e){e=Object.assign(Object.assign({},u.ScheduledFileMessageCreateParamsDefault),e),d.unless(u.validateScheduledFileMessageCreateParams(e)).throw(d.SendbirdError.invalidParameters);const t=Date.now(),s=this._generateRequestId(),n=new _.MessageRequestHandler;return d.sleep(h.PENDING_MESSAGE_DELAY).then((()=>{const i=this._createPendingScheduledFileMessage(e,s,t);d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){return n._trigger(i)}))))})),d.isFile(e.file)?this._uploadFileAndUpdateParams(e).then((()=>this._createScheduledFileMessage(e,n,s,t))):this._createScheduledFileMessage(e,n,s,t),n}updateScheduledFileMessage(e,t){return d.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},ht),t);d.unless((e=>h.validateBaseMessageUpdateParams(e)&&d.isTypeOf("number",e.scheduledAt,!0)&&(d.isFile(e.file)||d.isTypeOf("string",e.fileUrl))&&d.isTypeOf("string",e.fileName,!0)&&d.isTypeOf("string",e.mimeType,!0)&&d.isTypeOf("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((e=>d.isTypeOf("object",e)&&e.maxWidth>0&&e.maxHeight>0))))(s)).throw(d.SendbirdError.invalidParameters),d.isFile(s.file)&&(yield this._uploadFileAndUpdateParams(s));const n=new ct(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},s)),{requestQueue:i}=d.Vault.of(this._iid),a=yield i.send(n),{message:r}=a.as(_t);return r}))}cancelScheduledMessage(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=new mt({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),{requestQueue:s}=d.Vault.of(this._iid);yield s.send(t)}))}sendScheduledMessageNow(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=new gt({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),{requestQueue:s}=d.Vault.of(this._iid);yield s.send(t)}))}getMyPushTriggerOption(){return d.__awaiter(this,void 0,void 0,(function*(){const{sdkState:e,requestQueue:t}=d.Vault.of(this._iid),s=new Et({userId:e.userId,channelUrl:this.url}),n=yield t.send(s),{pushTriggerOption:i}=n.as(ft);return this.myPushTriggerOption=i,i}))}setMyPushTriggerOption(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isEnumOf(d.PushTriggerOption,e)).throw(d.SendbirdError.invalidParameters);const{dispatcher:t,sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new Ct({userId:s.userId,channelUrl:this.url,pushTriggerOption:e}),a=yield n.send(i),{pushTriggerOption:r}=a.as(vt);return this.myPushTriggerOption=r,t.dispatch(new u.GroupChannelUpdateEventCommand({channels:[this],source:u.GroupChannelEventSource.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),r}))}setMyCountPreference(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isEnumOf(exports.CountPreference,e)).throw(d.SendbirdError.invalidParameters);const{dispatcher:t,sdkState:s,requestQueue:n}=d.Vault.of(this._iid),i=new rt({channelUrl:this.url,userId:s.userId,countPreference:e}),a=yield n.send(i),{countPreference:r}=a.as(ot);return this.myCountPreference=r,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),t.dispatch(new u.GroupChannelUpdateEventCommand({channels:[this],source:u.GroupChannelEventSource.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),r}))}resetMyHistory(){return d.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:e,requestQueue:t}=d.Vault.of(this._iid),s=new lt({channelUrl:this.url}),n=yield t.send(s),{messageOffsetTimestamp:i}=n.as(dt);return this.messageOffsetTimestamp=i,this.lastMessage&&this.lastMessage.createdAt0).throw(d.SendbirdError.invalidParameters);const{requestQueue:t}=d.Vault.of(this._iid),s=new Mt({channelType:this.channelType,channelUrl:this.url,messageId:e});yield t.send(s)}))}unpinMessage(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isTypeOf("number",e)&&e>0).throw(d.SendbirdError.invalidParameters);const{requestQueue:t}=d.Vault.of(this._iid),s=new yt({channelType:this.channelType,channelUrl:this.url,messageId:e});yield t.send(s)}))}_uploadFileAndUpdateParams(e){return d.__awaiter(this,void 0,void 0,(function*(){if(d.isFile(e.file)){const{requestQueue:t}=d.Vault.of(this._iid),s=new _.UploadFileRequestCommand({file:e.file,channelUrl:this.url,thumbnailSizes:e.thumbnailSizes,requestId:this._generateRequestId()}),n=yield t.send(s),{url:i,fileSize:a=e.fileSize,thumbnailSizes:r=e.thumbnailSizes,requireAuth:o=!1}=n.as(_.UploadFileResponseCommand);e.fileUrl=i,e.fileSize=a,e.thumbnailSizes=r,e.requireAuth=o}}))}}const Pt={};class wt{constructor({_iid:e,limit:t=100}){this.ref=0,this._iid=e,this._limit=t;const{sdkState:s,dispatcher:n,logger:i}=d.Vault.of(this._iid);this._metadataKey=`sendbird:${s.userId}@groupchannel/sync.meta`;const a=(e=>`sendbird:${e}@groupchannel/sync`)(s.userId);this._sync=new Te(a,(()=>d.__awaiter(this,void 0,void 0,(function*(){var e,t,s,n;const a={hasNext:!0,nextToken:""};if(yield this.loadMetadata(),i.debug("channel background sync from",null===(e=this._metadata)||void 0===e?void 0:e.token),null===(t=this._metadata)||void 0===t?void 0:t.completed)a.hasNext=!1,a.nextToken="";else try{const e=Ae.of(this._iid),{channels:t,token:r}=yield e.getMyGroupChannels(null!==(n=null===(s=this._metadata)||void 0===s?void 0:s.token)&&void 0!==n?n:"",{includeEmpty:!0,order:u.GroupChannelListOrder.CHRONOLOGICAL},this._limit,u.GroupChannelEventSource.SYNC_CHANNEL_BACKGROUND);a.hasNext=t.length>=this._limit&&!!r,a.nextToken=r,this._metadata&&(this._metadata.token=r,this._metadata.range.extends(...t.map((e=>e.createdAt))),this._metadata.completed=!a.hasNext),i.debug("channel background sync progress",a),yield this.saveMetadata()}catch(e){throw i.debug("channel background sync error",e),e instanceof d.SendbirdError&&e.isInvalidTokenError&&(yield this.clearMetaData()),e}return a})))),this._connectionEventContext=n.on((e=>{if(e instanceof d.ConnectionStateChangeCommand)if(e.stateType===d.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e){return Pt[e]||(Pt[e]=new wt({_iid:e})),Pt[e].ref++,Pt[e]}static clear(e){Pt[e]&&(Pt[e].close(),delete Pt[e])}get range(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new ye({})}get completed(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)}loadMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:e}=d.Vault.of(this._iid),t=yield e.preference.get(this._metadataKey);this._metadata={token:t?t.token:"",range:new ye(t?t.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!t&&t.completed}}return this._metadata}))}saveMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._metadata){const{cacheContext:e}=d.Vault.of(this._iid);return yield e.preference.set(this._metadataKey,this._metadata),!0}return!1}))}clearMetaData(){return d.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:e}=d.Vault.of(this._iid);yield e.preference.remove(this._metadataKey),this._metadata=void 0}))}resume(){var e,t;const{logger:s,connectionManager:n}=d.Vault.of(this._iid);n.isConnected&&(s.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:""))}pause(){const{logger:e}=d.Vault.of(this._iid);e.debug("channel background sync stop()"),this._sync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete Pt[this._iid])}}const xt={};class Rt{constructor({_iid:e}){this.ref=0,this._iid=e;const{logger:t,sdkState:s,dispatcher:n}=d.Vault.of(this._iid);this._metadataKey=`sendbird:${s.userId}@groupchannel/changelogs.meta`;const i=(e=>`sendbird:${e}@groupchannel/changelogs`)(s.userId);this._sync=new Te(i,(()=>d.__awaiter(this,void 0,void 0,(function*(){var e,s,n;const i={hasNext:!0,nextToken:0};yield this.loadMetadata(),t.debug("channel changelog sync from",null===(e=this._metadata)||void 0===e?void 0:e.token);try{const e=Ae.of(this._iid),{hasMore:a,token:r}=yield e.getMyGroupChannelChangeLogs(null!==(n=null===(s=this._metadata)||void 0===s?void 0:s.token)&&void 0!==n?n:"",{includeEmpty:!0},u.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS);i.hasNext=a,i.nextToken=r,this._metadata&&(this._metadata.token=r),t.debug("channel changelog sync progress",i),yield this.saveMetadata()}catch(e){throw t.debug("channel changelog sync error",e),e instanceof d.SendbirdError&&e.isInvalidTokenError&&(yield this.clearMetadata()),e}return i})))),this._connectionEventContext=n.on((e=>{if(e instanceof d.ConnectionStateChangeCommand)if(e.stateType===d.ConnectionStateType.CONNECTED)this.resume();else this.pause()}))}static of(e){return xt[e]||(xt[e]=new Rt({_iid:e})),xt[e].ref++,xt[e]}static clear(e){xt[e]&&(xt[e].close(),delete xt[e])}loadMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){if(!this._metadata){const{cacheContext:e,firstConnectedAt:t}=d.Vault.of(this._iid),s=yield e.preference.get(this._metadataKey);this._metadata={token:s?s.token:t}}return this._metadata}))}saveMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._metadata){const{cacheContext:e}=d.Vault.of(this._iid);return yield e.preference.set(this._metadataKey,this._metadata),!0}return!1}))}clearMetadata(){return d.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:e}=d.Vault.of(this._iid);yield e.preference.remove(this._metadataKey),this._metadata=void 0}))}resume(){const{connectionManager:e}=d.Vault.of(this._iid);e.isConnected&&this._sync.start(0)}pause(){this._sync.stop()}close(){this.ref--,this.ref<=0&&(this.ref=0,this.pause(),this._connectionEventContext.close(),delete xt[this._iid])}}class Lt{constructor(e,{filter:t,order:s,limit:n}){this.channels=[],this._iid=e,this._key=`gcc-${d.uuid()}`,this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this.filter=null!=t?t:new C,this.order=null!=s?s:u.GroupChannelListOrder.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=n?n:h.DEFAULT_GROUPCHANNEL_LIMIT;const{sdkState:i,cacheContext:a,dispatcher:r}=d.Vault.of(this._iid);a.localCacheEnabled&&(this._backgroundSync=wt.of(e),this._backgroundSync.resume()),this._changelogSync=Rt.of(e),this._changelogSync.resume();Ae.of(this._iid).subscribeGroupChannelEvent(this._key,{onUpdate:(e,t)=>{if(u.shouldGiveEvent(t)){const s=e.filter((e=>this.filter.match(e,i.userId))),n=e.filter((e=>!this.filter.match(e,i.userId))).map((e=>e.url));s.length>0&&this._addChannelsToView(s,t),n.length>0&&this._removeChannelsFromView(n,t)}},onRemove:(e,t)=>{this._removeChannelsFromView(e,t)}});const{statLogCollector:o}=d.Vault.of(this._iid);o.put(new d.DailyRecordStatLog({type:d.StatType.FEATURE_LOCALCACHE,data:{use_local_cache:a.localCacheEnabled,collection_interface:{group_channel:!0}}})),r.on((e=>{e instanceof d.ConnectionStateChangeCommand&&(e.stateType===d.ConnectionStateType.CONNECTED?this._isGetRemoteChannelsSucceeded||(()=>{d.__awaiter(this,void 0,void 0,(function*(){yield this._revokeLoadMore()}))})():e.stateType===d.ConnectionStateType.LOGOUT&&this.dispose())}))}get hasMore(){return!this._isDisposed&&this._hasMore}setGroupChannelCollectionHandler(e){this._handler=e}_addChannelsToView(e,t,s=!1){const n=[],i=[],a=[];for(const r of e){const e=De(this.channels,r);e>=0&&this.channels.splice(e,1);const{place:o}=Ge(this.channels,r,this.order);if(e<0)o===this.channels.length?!s&&this._hasMore||(n.push(r),this.channels.push(r)):(n.push(r),this.channels.splice(o,0,r));else switch(t){case u.GroupChannelEventSource.EVENT_CHANNEL_UPDATED:case u.GroupChannelEventSource.EVENT_MESSAGE_RECEIVED:case u.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS:case u.GroupChannelEventSource.EVENT_MESSAGE_SENT:o!==e&&this._hasMore&&o===this.channels.length?a.push(r):(this.channels.splice(o,0,r),i.push(r));break;default:this.channels.splice(o,0,r),i.push(r)}}if(a.length>0)for(const e of a){const t=De(this.channels,e);-1!==t&&this.channels.splice(t,1)}u.shouldGiveEvent(t)&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e,s,r;const o=new Ne(t);n.length>0&&(null===(e=this._handler)||void 0===e?void 0:e.onChannelsAdded)&&this._handler.onChannelsAdded(o,n),i.length>0&&(null===(s=this._handler)||void 0===s?void 0:s.onChannelsUpdated)&&this._handler.onChannelsUpdated(o,i),a.length>0&&(null===(r=this._handler)||void 0===r?void 0:r.onChannelsDeleted)&&this._handler.onChannelsDeleted(o,a.map((e=>e.url)))}))))}_removeChannelsFromView(e,t){const s=[];for(const t of e){const e=this.channels.findIndex((e=>e.url===t));e>=0&&(s.push(this.channels[e].url),this.channels.splice(e,1))}return u.shouldGiveEvent(t)&&s.length>0&&d.runAsCallback((()=>d.__awaiter(this,void 0,void 0,(function*(){var e;const n=new Ne(t);(null===(e=this._handler)||void 0===e?void 0:e.onChannelsDeleted)&&this._handler.onChannelsDeleted(n,s)})))),s}_getLocalChannels(){return d.__awaiter(this,void 0,void 0,(function*(){const e=Ae.of(this._iid),t=this.channels.length>0?((e,t)=>{var s,n,i,a;switch(t){case u.GroupChannelListOrder.LATEST_LAST_MESSAGE:return null!==(n=null===(s=e.lastMessage)||void 0===s?void 0:s.createdAt)&&void 0!==n?n:e.createdAt;case u.GroupChannelListOrder.CHRONOLOGICAL:return e.createdAt;case u.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return e.name;default:return null!==(a=null===(i=e.lastMessage)||void 0===i?void 0:i.createdAt)&&void 0!==a?a:e.createdAt}})(this.channels[this.channels.length-1],this.order):null;return yield e.getChannelsFromCache(t,this.filter,this.order,this._limit,t?this.channels[this.channels.length-1].url:void 0)}))}_getRemoteChannels(){return d.__awaiter(this,void 0,void 0,(function*(){const e=Ae.of(this._iid),{channels:t,token:s}=yield e.getMyGroupChannels(this._token,d.undefineNullProps(Object.assign(Object.assign({},this.filter),{order:this.order})),this._limit);return this._token=s,this._hasMore=!!s,t}))}_revokeLoadMore(){return d.__awaiter(this,void 0,void 0,(function*(){if(!this._isDisposed)try{const e=yield this._getRemoteChannels();this._isGetRemoteChannelsSucceeded=!0,this._addChannelsToView(e,u.GroupChannelEventSource.REQUEST_CHANNEL,!0)}catch(e){this._isGetRemoteChannelsSucceeded=!1}}))}loadMore(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._isDisposed)throw new d.SendbirdError({code:d.SendbirdErrorCode.COLLECTION_DISPOSED,message:"Collection has been disposed."});if(this._hasMore){const{cacheContext:e}=d.Vault.of(this._iid);let t=[];if(e.localCacheEnabled&&this._backgroundSync.completed)yield d.runOrNothing((()=>d.__awaiter(this,void 0,void 0,(function*(){t=yield this._getLocalChannels()})))),this._hasMore=t.length>=this._limit;else try{t=yield this._getRemoteChannels(),this._isGetRemoteChannelsSucceeded=!0}catch(e){this._isGetRemoteChannelsSucceeded=!1}return this._addChannelsToView(t,u.GroupChannelEventSource.REQUEST_CHANNEL,!0),t}return[]}))}dispose(){var e,t;if(this._isDisposed)return;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();Ae.of(this._iid).unsubscribeGroupChannelEvent(this._key)}}class Ft extends d.APIRequestCommand{constructor(e){const{token:t,limit:s,order:n,includeEmpty:i,membershipFilter:a,channelNameContainsFilter:r,channelUrlsFilter:o,customTypesFilter:l,customTypeStartsWithFilter:h,superChannelFilter:u,metadataOrderKeyFilter:c,metadataKey:_,metadataValues:p,metadataValueStartsWith:m,includeFrozen:g,includeMetaData:C}=e;super(),this.method=d.APIRequestMethod.GET,this.path=d.API_PATH_GROUP_CHANNELS,this.params=d.deundefined(d.undefineNullProps({token:t,limit:s,order:n,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:i,public_mode:exports.PublicChannelFilter.PUBLIC,public_membership_mode:a,name_contains:r,channel_urls:o,custom_types:l,custom_type_startswith:h,super_mode:u,metadata_order_key:c,metadata_key:_,metadata_values:p,metadata_value_startswith:m,show_frozen:g,show_metadata:C}))}}class kt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.channels=[];const{next:s,channels:n,ts:i}=t;this.token=s,n&&n.length>0&&(this.channels=n.map((t=>(t.ts=i,new Ot(e,t))))),this.ts="number"==typeof i?i:0}}var Dt;exports.MembershipFilter=void 0,(Dt=exports.MembershipFilter||(exports.MembershipFilter={})).ALL="all",Dt.JOINED="joined";class Gt extends d.BaseListQuery{constructor(e,t){var s,n,i,a,r,o,l,d,h,c,_,p,m,g;super(e,t),this.includeEmpty=!1,this.includeFrozen=!0,this.includeMetaData=!0,this.channelUrlsFilter=null,this.customTypesFilter=null,this.customTypeStartsWithFilter=null,this.channelNameContainsFilter=null,this.membershipFilter=exports.MembershipFilter.ALL,this.superChannelFilter=exports.SuperChannelFilter.ALL,this.metadataKey=null,this.metadataValues=null,this.metadataOrderKeyFilter=null,this.metadataValueStartsWith=null,this.order=u.PublicGroupChannelListOrder.CHRONOLOGICAL,this.includeEmpty=null!==(s=t.includeEmpty)&&void 0!==s&&s,this.includeFrozen=null===(n=t.includeFrozen)||void 0===n||n,this.includeMetaData=null===(i=t.includeMetaData)||void 0===i||i,this.channelUrlsFilter=null!==(a=t.channelUrlsFilter)&&void 0!==a?a:null,this.customTypesFilter=null!==(r=t.customTypesFilter)&&void 0!==r?r:null,this.customTypeStartsWithFilter=null!==(o=t.customTypeStartsWithFilter)&&void 0!==o?o:null,this.channelNameContainsFilter=null!==(l=t.channelNameContainsFilter)&&void 0!==l?l:null,this.membershipFilter=null!==(d=t.membershipFilter)&&void 0!==d?d:exports.MembershipFilter.ALL,this.superChannelFilter=null!==(h=t.superChannelFilter)&&void 0!==h?h:exports.SuperChannelFilter.ALL,this.metadataKey=null!==(c=t.metadataKey)&&void 0!==c?c:null,this.metadataValues=null!==(_=t.metadataValues)&&void 0!==_?_:null,this.metadataOrderKeyFilter=null!==(p=t.metadataOrderKeyFilter)&&void 0!==p?p:null,this.metadataValueStartsWith=null!==(m=t.metadataValueStartsWith)&&void 0!==m?m:null,this.order=null!==(g=t.order)&&void 0!==g?g:u.PublicGroupChannelListOrder.CHRONOLOGICAL}_validate(){return super._validate()&&d.isTypeOf("boolean",this.includeEmpty)&&d.isTypeOf("boolean",this.includeFrozen)&&d.isTypeOf("boolean",this.includeMetaData)&&d.isTypeOf("string",this.channelNameContainsFilter,!0)&&d.isArrayOf("string",this.channelUrlsFilter,!0)&&d.isArrayOf("string",this.customTypesFilter,!0)&&d.isTypeOf("string",this.customTypeStartsWithFilter,!0)&&d.isEnumOf(exports.MembershipFilter,this.membershipFilter)&&d.isEnumOf(exports.SuperChannelFilter,this.superChannelFilter)&&d.isEnumOf(u.PublicGroupChannelListOrder,this.order)&&d.isTypeOf("string",this.metadataOrderKeyFilter,!0)&&d.isTypeOf("string",this.metadataKey,!0)&&d.isArrayOf("string",this.metadataValues,!0)&&d.isTypeOf("string",this.metadataValueStartsWith,!0)}next(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw d.SendbirdError.queryInProgress;{const e=[];if(this._hasNext){this._isLoading=!0;const{requestQueue:e,dispatcher:t}=d.Vault.of(this._iid),s=new Ft(d.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),n=yield e.send(s),{channels:i,token:a}=n.as(kt);return this._token=a,this._hasNext=!!a,this._isLoading=!1,i}return e}}throw d.SendbirdError.invalidParameters}))}}class Ht extends c.BaseChannelHandlerParams{constructor(){super(...arguments),this.onUserJoined=d.noop,this.onUserLeft=d.noop,this.onUserReceivedInvitation=d.noop,this.onUserDeclinedInvitation=d.noop,this.onChannelHidden=d.noop,this.onUnreadMemberStatusUpdated=d.noop,this.onUndeliveredMemberStatusUpdated=d.noop,this.onTypingStatusUpdated=d.noop,this.onPollUpdated=d.noop,this.onPollVoted=d.noop,this.onPollDeleted=d.noop,this.onPinnedMessageUpdated=d.noop}}class Vt extends Ht{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class qt extends d.APIRequestCommand{constructor(e){const{token:t,limit:s,order:n,reverse:i,channelUrl:a,messageTypeFilter:r,scheduledStatus:o}=e;super(),this.method=d.APIRequestMethod.GET,this.path=`${d.API_PATH_SCHEDULED_MESSAGES}`,this.params=d.deundefined(d.undefineNullProps({token:t,limit:s,reverse:i,channel_url:a,order:n,message_type:r,status:o}))}}class jt extends d.APIResponseCommand{constructor(e,t){super(e,t),this.scheduledMessages=[];const{next:s,scheduled_messages:n}=t;this.token=s,this.scheduledMessages=n.map((t=>_.parseMessagePayload(e,t)))}}class Bt extends d.BaseListQuery{constructor(e,t){var s,n,i,a,r;super(e,t),this.channelUrl=null,this.order=null,this.reverse=!1,this.scheduledStatus=null,this.messageTypeFilter=d.MessageTypeFilter.ALL,this.channelUrl=null!==(s=t.channelUrl)&&void 0!==s?s:null,this.order=null!==(n=t.order)&&void 0!==n?n:null,this.reverse=null!==(i=t.reverse)&&void 0!==i&&i,this.scheduledStatus=null!==(a=t.scheduledStatus)&&void 0!==a?a:null,this.messageTypeFilter=null!==(r=t.messageTypeFilter)&&void 0!==r?r:d.MessageTypeFilter.ALL}_validate(){return super._validate()&&d.isTypeOf("string",this.channelUrl,!0)&&(d.isEnumOf(u.ScheduledMessageListOrder,this.order)||null===this.order)&&d.isTypeOf("boolean",this.reverse)&&(d.isArrayOf(_.ScheduledStatus,this.scheduledStatus)||null===this.scheduledStatus)&&d.isEnumOf(d.MessageTypeFilter,this.messageTypeFilter)}next(){return d.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw d.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=d.Vault.of(this._iid),t=new qt(d.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),s=yield e.send(t),{scheduledMessages:n,token:i}=s.as(jt);return this._token=i,this._hasNext=!!i,this._isLoading=!1,n}return[]}throw d.SendbirdError.invalidParameters}))}}class Wt extends d.Module{constructor(){super(...arguments),this.name="groupChannel"}init(e,{sdkState:t,dispatcher:s,sessionManager:n,requestQueue:i,logger:a,onlineDetector:r,cacheContext:o}){super.init(e,{sdkState:t,dispatcher:s,sessionManager:n,requestQueue:i,logger:a,onlineDetector:r,cacheContext:o}),this._manager=new Ae(e,{sdkState:t,cacheContext:o,dispatcher:s,sessionManager:n,requestQueue:i,logger:a})}createGroupChannelCollection(e={}){return new Lt(this._iid,e)}createMyGroupChannelListQuery(e={}){return new Me(this._iid,e)}createPublicGroupChannelListQuery(e={}){return new Gt(this._iid,e)}createScheduledMessageListQuery(e={}){return new Bt(this._iid,e)}addGroupChannelHandler(e,t){d.unless(d.isTypeOf("string",e)&&t instanceof Vt).throw(d.SendbirdError.invalidParameters),this._manager.addHandler(e,t)}removeGroupChannelHandler(e){d.unless(d.isTypeOf("string",e)).throw(d.SendbirdError.invalidParameters),this._manager.removeHandler(e)}removeAllGroupChannelHandlers(){this._manager.clearHandler()}buildGroupChannelFromSerializedData(e){return this._manager.buildGroupChannelFromSerializedData(e)}buildGroupChannelListQueryFromSerializedData(e){return this._manager.buildGroupChannelListQueryFromSerializedData(e)}buildMemberFromSerializedData(e){return this._manager.buildMemberFromSerializedData(e)}getChannel(e){return d.__awaiter(this,void 0,void 0,(function*(){return d.unless(d.isTypeOf("string",e)).throw(d.SendbirdError.invalidParameters),this._manager.getChannel(e)}))}getChannelWithoutCache(e){return d.__awaiter(this,void 0,void 0,(function*(){return d.unless(d.isTypeOf("string",e)).throw(d.SendbirdError.invalidParameters),this._manager.getChannelWithoutCache(e)}))}getMyGroupChannelChangeLogsByToken(e,t={}){return d.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},M),t);return d.unless(d.isTypeOf("string",e)&&y(s)).throw(d.SendbirdError.invalidParameters),yield this._manager.getMyGroupChannelChangeLogs(e,s)}))}getMyGroupChannelChangeLogsByTimestamp(e,t={}){return d.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},M),t);return d.unless(d.isTypeOf("number",e)&&y(s)).throw(d.SendbirdError.invalidParameters),yield this._manager.getMyGroupChannelChangeLogs(e,s)}))}getGroupChannelCount(e){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},S),e);return d.unless(b(t)).throw(d.SendbirdError.invalidParameters),this._manager.getGroupChannelCount(t)}))}getUnreadItemCount(e={}){return d.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getUnreadItemCount(e)}))}getTotalUnreadChannelCount(){return d.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalUnreadChannelCount()}))}getTotalUnreadMessageCount(e={}){return d.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalUnreadMessageCount(e)}))}getTotalScheduledMessageCount(e={}){return d.__awaiter(this,void 0,void 0,(function*(){return yield this._manager.getTotalScheduledMessageCount(e)}))}getSubscribedTotalUnreadMessageCount(){return this._manager.getSubscribedTotalUnreadMessageCount()}getSubscribedCustomTypeTotalUnreadMessageCount(){return this._manager.getSubscribedCustomTypeTotalUnreadMessageCount()}getSubscribedCustomTypeUnreadMessageCount(e){return this._manager.getSubscribedCustomTypeUnreadMessageCount(e)}createChannel(e={}){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},E),e);return d.unless(f(t)).throw(d.SendbirdError.invalidParameters),this._manager.createChannel(t)}))}createDistinctChannelIfNotExist(e={}){return d.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},E),e);return d.unless(f(t)).throw(d.SendbirdError.invalidParameters),t&&(t.isDistinct=!0),this.createChannel(t)}))}createChannelWithUserIds(e,t=!1,s,n,i="",a=""){return d.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},E),{invitedUserIds:e,isDistinct:t,name:s,data:i,customType:a});return"string"==typeof n?r.coverUrl=n:r.coverImage=n,this.createChannel(r)}))}markAsReadAll(){return d.__awaiter(this,void 0,void 0,(function*(){this._manager.markAsReadAll()}))}markAsReadWithChannelUrls(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isArrayOf("string",e)).throw(d.SendbirdError.invalidParameters),this._manager.markAsReadWithChannelUrls(e)}))}markAsDelivered(e){return d.__awaiter(this,void 0,void 0,(function*(){d.unless(d.isTypeOf("string",e)).throw(d.SendbirdError.invalidParameters);const t=yield this.getChannel(e);yield t.markAsDelivered()}))}}Object.defineProperty(exports,"MessageEventSource",{enumerable:!0,get:function(){return d.MessageEventSource}}),Object.defineProperty(exports,"GroupChannelEventSource",{enumerable:!0,get:function(){return u.GroupChannelEventSource}}),Object.defineProperty(exports,"GroupChannelListOrder",{enumerable:!0,get:function(){return u.GroupChannelListOrder}}),exports.MessageFilter=u.MessageFilter,Object.defineProperty(exports,"PublicGroupChannelListOrder",{enumerable:!0,get:function(){return u.PublicGroupChannelListOrder}}),Object.defineProperty(exports,"ScheduledMessageListOrder",{enumerable:!0,get:function(){return u.ScheduledMessageListOrder}}),Object.defineProperty(exports,"ScheduledStatus",{enumerable:!0,get:function(){return _.ScheduledStatus}}),exports.GroupChannel=Ot,exports.GroupChannelCollection=Lt,exports.GroupChannelEventContext=Ne,exports.GroupChannelFilter=C,exports.GroupChannelHandler=Vt,exports.GroupChannelListQuery=Me,exports.GroupChannelModule=Wt,exports.Member=m,exports.MemberListQuery=Ze,exports.MessageCollection=$e,exports.MessageCollectionInitHandler=We,exports.MessageEventContext=Ie,exports.PinnedMessage=St,exports.PinnedMessageListQuery=Ut,exports.PublicGroupChannelListQuery=Gt,exports.ReadStatus=g,exports.ScheduledMessageListQuery=Bt; diff --git a/cjs/index.js b/cjs/index.js new file mode 100644 index 0000000..5314be1 --- /dev/null +++ b/cjs/index.js @@ -0,0 +1 @@ +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-032c97c6.js"),t=require("./message.js"),s=require("./poll.js"),n=require("./lib/__bundle-aa0921e3.js"),r=require("./lib/__bundle-c8f25be2.js"),i=require("./lib/__bundle-7e34e7ed.js"),o=require("./lib/__bundle-481ecf03.js"),a=require("./lib/__bundle-91cccea4.js");const d={profileImage:void 0,profileUrl:void 0,nickname:void 0};class u{constructor(){this.onSessionExpired=e.noop,this.onSessionTokenRequired=e=>e(null),this.onSessionError=e.noop,this.onSessionRefreshed=e.noop,this.onSessionClosed=e.noop}}class c extends u{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class l{constructor(){this.onConnected=e.noop,this.onReconnectStarted=e.noop,this.onReconnectSucceeded=e.noop,this.onReconnectFailed=e.noop,this.onDisconnected=e.noop}}class h extends l{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}class p{constructor(){this.onFriendsDiscovered=e.noop,this.onTotalUnreadMessageCountUpdated=e.noop}}class _ extends p{constructor(e={}){super(),Object.keys(e).forEach((t=>{this.hasOwnProperty(t)&&(this[t]=e[t])}))}}const m=(t,s)=>(i,o)=>{if(1===i)t.clear().then((()=>{s.clear().then((()=>{(t=>e.__awaiter(void 0,void 0,void 0,(function*(){return t.commitSchema([{collectionName:n.NESTDB_GROUPCHANNEL_COLLECTION_NAME,keyName:n.NESTDB_GROUPCHANNEL_COLLECTION_KEY,index:[r.getGroupChannelIndexBy(r.GroupChannelListOrder.LATEST_LAST_MESSAGE),r.getGroupChannelIndexBy(r.GroupChannelListOrder.CHRONOLOGICAL),r.getGroupChannelIndexBy(r.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:n.NESTDB_MESSAGE_COLLECTION_NAME,keyName:n.NESTDB_MESSAGE_COLLECTION_KEY,index:[r.getMessageIndexBy(r.MessageListOrder.CHANNEL_LATEST),r.getMessageIndexBy(r.MessageListOrder.NEWEST_CHILD_MESSAGE)]},{collectionName:r.NESTDB_UNSENT_MESSAGE_COLLECTION_NAME,keyName:r.NESTDB_UNSENT_MESSAGE_COLLECTION_KEY,index:[r.getMessageIndexBy(r.MessageListOrder.CHANNEL_LATEST),r.getMessageIndexBy(r.MessageListOrder.NEWEST_CHILD_MESSAGE)]},{collectionName:n.NESTDB_POLL_COLLECTION_NAME,keyName:n.NESTDB_POLL_COLLECTION_KEY}])})))(t).then((()=>o())).catch((e=>o(e)))})).catch((e=>o(e)))})).catch((e=>o(e)));else o()},f=()=>"undefined"!=typeof document?document.visibilityState:"visible";class g extends e.EventDispatcher{constructor({getVisibilityState:e=f,initialState:t="visible",isEnabled:s=!0,pauseCheckDelay:n=3e4}){super(),this._pauseCheckDelay=3e4,this._currentState="visible",this._getVisibilityState=e,this._pauseCheckDelay=n,this._currentState=t,this._isEnabled=s,this._boundToggleState=this._toggleState.bind(this)}get currentState(){return this._currentState}get isAvailable(){return"undefined"!=typeof window&&!!window.addEventListener&&!!window.removeEventListener}_toggleState(){const e=this._getVisibilityState();"hidden"!==e?"hidden"===this._currentState&&(this._pauseDelayTimer&&(clearTimeout(this._pauseDelayTimer),this._pauseDelayTimer=void 0),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((()=>{this._pauseDelayTimer=void 0,this.dispatch("pause")}),this._pauseCheckDelay)),this._currentState=e}start(){this._isEnabled&&this.isAvailable&&(this._boundToggleState=this._toggleState.bind(this),window.addEventListener("visibilitychange",this._boundToggleState,{capture:!0}))}stop(){this._isEnabled&&this.isAvailable&&this._boundToggleState&&window.removeEventListener("visibilitychange",this._boundToggleState,{capture:!0})}}class I{constructor({logger:e,connectionDelegate:t=null}){this._onlineWorker=()=>{var e;return null===(e=this.connectionDelegate)||void 0===e?void 0:e.reconnect()},this._offlineWorker=()=>{var e;return null===(e=this.connectionDelegate)||void 0===e?void 0:e.disconnect()},this.unsubscribes=[],this._onlineListener=e=>{if(this.isAvailableOnWeb)return window.addEventListener("online",e),()=>window.removeEventListener("online",e,!1)},this._offlineListener=e=>{if(this.isAvailableOnWeb)return window.addEventListener("offline",e),()=>window.removeEventListener("offline",e,!1)},this.logger=e,t&&(this.connectionDelegate=t)}get isAvailableOnWeb(){return"undefined"!=typeof window&&!!window.addEventListener&&"ononline"in window&&"onoffline"in window&&"undefined"!=typeof navigator&&void 0!==navigator.onLine}setOnlineListener(e){Boolean(e)&&"function"==typeof e&&(this._onlineListener=e)}setOfflineListener(e){Boolean(e)&&"function"==typeof e&&(this._offlineListener=e)}start(){this.unsubscribes=[this._onlineListener(this._onlineWorker),this._offlineListener(this._offlineWorker)]}stop(){this.unsubscribes.forEach((e=>{try{null==e||e()}catch(e){this.logger.warn(e.message)}})),this.unsubscribes=[]}isOnline(){return e.__awaiter(this,void 0,void 0,(function*(){return this.isAvailableOnWeb?navigator.onLine:new Promise((t=>{fetch("https://www.google.com",{method:e.APIRequestMethod.GET,mode:"no-cors"}).then((()=>t(!0))).catch((()=>t(!1)))}))}))}}class S extends e.APIRequestCommand{constructor({userId:t,nickname:s,profileUrl:n,profileImage:r,preferredLanguages:i}){super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}`,this.params=e.deundefined(e.undefineNullProps({nickname:s,profile_url:n,profile_file:r,preferred_languages:i}))}}class v extends e.APIResponseCommand{constructor(t,s){super(t,s),this.user=new e.User(t,Object.assign({},s))}}class P extends e.APIRequestCommand{constructor({userId:t,token:s}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/apns`,this.params={apns_device_token:s,always_push:!0}}}class y extends e.APIRequestCommand{constructor({userId:t,token:s}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/gcm`,this.params={gcm_reg_token:s,always_push:!0}}}class C extends e.APIRequestCommand{constructor({userId:t,token:s}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/apns/${encodeURIComponent(s)}`}}class T extends e.APIRequestCommand{constructor({userId:t,token:s}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/gcm/${encodeURIComponent(s)}`}}class A extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/apns`}}class E extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/gcm`}}class b extends e.APIRequestCommand{constructor({userId:t,type:s,token:n,ts:r}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/${encodeURIComponent(s)}/device_tokens`,this.params={created_ts:r,token:n}}}class w extends e.APIResponseCommand{constructor(t,s){super(t,s),this.pushTokens={type:s.type?e.PushTokenType[s.type.toLowerCase()]:e.PushTokenType.UNKNOWN,deviceTokens:s.device_tokens,hasMore:s.has_more,token:s.token}}}class k extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/channel_invitation_preference`}}class R extends e.APIResponseCommand{constructor(e,t){super(e,t),this.autoAccept=t.auto_accept}}class U extends e.APIRequestCommand{constructor({userId:t,willAutoAccept:s}){super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/channel_invitation_preference`,this.params={auto_accept:s}}}class O extends e.APIResponseCommand{constructor(e,t){super(e,t),this.autoAccept=t.auto_accept}}class x extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`}}class M extends e.APIResponseCommand{constructor(e,t){super(e,t),this.preference={doNotDisturbOn:t.do_not_disturb,startHour:t.start_hour,startMin:t.start_min,endHour:t.end_hour,endMin:t.end_min,timezone:t.timezone}}}class D extends e.APIRequestCommand{constructor({userId:t,doNotDisturbOn:s,startHour:n,startMin:r,endHour:i,endMin:o,timezone:a}){super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`,this.params={do_not_disturb:s,start_hour:n,start_min:r,end_hour:i,end_min:o,timezone:a}}}class q extends e.APIResponseCommand{constructor(e,t){super(e,t),this.preference={doNotDisturbOn:t.do_not_disturb,startHour:t.start_hour,startMin:t.start_min,endHour:t.end_hour,endMin:t.end_min,timezone:t.timezone}}}class L extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`}}class N extends e.APIResponseCommand{constructor(e,t){super(e,t),this.snoozePeriod={isSnoozeOn:t.snooze_enabled},"number"==typeof t.snooze_start_ts&&(this.snoozePeriod.startTs=t.snooze_start_ts),"number"==typeof t.snooze_end_ts&&(this.snoozePeriod.endTs=t.snooze_end_ts)}}class V extends e.APIRequestCommand{constructor({userId:t,snoozeOn:s,startTs:n,endTs:r}){super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`,this.params={snooze_enabled:s,snooze_start_ts:n,snooze_end_ts:r}}}class $ extends e.APIResponseCommand{constructor(e,t){super(e,t),this.snoozePeriod={isSnoozeOn:t.snooze_enabled},"number"==typeof t.snooze_start_ts&&(this.snoozePeriod.startTs=t.snooze_start_ts),"number"==typeof t.snooze_end_ts&&(this.snoozePeriod.endTs=t.snooze_end_ts)}}class H extends e.APIRequestCommand{constructor({userId:t,blockedUserId:s}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/block`,this.params={target_id:s}}}class F extends e.APIRequestCommand{constructor({userId:t,unblockedUserId:s}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/block/${encodeURIComponent(s)}`}}class Q extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`}}class j extends e.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option}}class z extends e.APIRequestCommand{constructor({userId:t,pushTriggerOption:s}){super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push_preference`,this.params={push_trigger_option:s}}}class G extends e.APIResponseCommand{constructor(e,t){super(e,t),this.pushTriggerOption=t.push_trigger_option}}class B extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/template`}}class K extends e.APIResponseCommand{constructor(e,t){super(e,t),this.name=t.name}}class W extends e.APIRequestCommand{constructor({userId:t,templateName:s}){super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/push/template`,this.params={name:s}}}class J extends e.APIResponseCommand{constructor(e,t){super(e,t),this.name=t.name}}class Y extends e.APIRequestCommand{constructor({userId:t,token:s}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/friends/changelogs`,this.params={token:s}}}class X extends e.APIResponseCommand{constructor(t,s){super(t,s),this.changelogs={addedUsers:s.added.map((s=>new e.User(t,s))),updatedUsers:s.updated.map((s=>new e.User(t,s))),deletedUserIds:s.deleted,hasMore:s.has_more,token:s.next}}}class Z extends e.APIRequestCommand{constructor({userId:t,discoveries:s}){super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/friend_discoveries`,this.params={friend_discoveries:s.map((e=>({friend_discovery_key:e.friendDiscoveryKey,friend_name:e.friendName})))}}}class ee extends e.APIResponseCommand{constructor(e,t){super(e,t),this.friendDiscoveryRequestId=t.friend_discovery_request_id}}class te extends e.APIRequestCommand{constructor({userId:t,discoveryKeys:s}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/friend_discoveries`,this.params={friend_discovery_keys:s}}}class se extends e.APIRequestCommand{constructor({userId:t,userIds:s}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/friends`,this.params={user_ids:s}}}class ne extends e.APIResponseCommand{constructor(t,s){super(t,s),this.users=s.users.map((s=>new e.User(t,s)))}}class re extends e.APIRequestCommand{constructor({userId:t,userIds:s}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/friends`,this.params={user_ids:s}}}class ie extends e.APIRequestCommand{constructor({userId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${t}/allow_friend_discovery`,this.params={}}}class oe extends e.APIResponseCommand{constructor(e,t){super(e,t),this.allowFriendDiscovery=t.allow_friend_discovery}}class ae extends e.APIRequestCommand{constructor({userId:t,allowFriendDiscovery:s}){super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_USERS}/${t}/allow_friend_discovery`,this.params={allow_friend_discovery:s}}}class de{constructor(e){this.key=e.key,this.url=e.url}}class ue{constructor(e){this.id=e.id,this.name=e.name,this.url=e.url,this.emojis=e.emojis?e.emojis.map((e=>new de(e))):[]}}class ce{constructor(e){this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map((e=>new ue(e))):[]}}class le extends e.APIRequestCommand{constructor(){super(),this.method=e.APIRequestMethod.GET,this.path=e.API_PATH_EMOJI_CATEGORIES}}class he extends e.APIResponseCommand{constructor(e,t){super(e,t),this.emojiContainer=new ce(t)}}class pe extends e.APIRequestCommand{constructor({categoryId:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_EMOJI_CATEGORIES}/${t}`}}class _e extends e.APIResponseCommand{constructor(e,t){super(e,t),this.emojiCategory=new ue(t)}}class me extends e.APIRequestCommand{constructor({key:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_EMOJIS}/${t}`}}class fe extends e.APIResponseCommand{constructor(e,t){super(e,t),this.emoji=new de(t)}}class ge extends e.APIRequestCommand{constructor(){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_UIKIT_CONFIGURATION}`}}class Ie extends e.APIResponseCommand{constructor(e,t){var s;super(e,t);const n=null!=t?t:{};this.uikitConfiguration={string:JSON.stringify(n),json:n},this.updatedAt=null!==(s=null==t?void 0:t.updated_at)&&void 0!==s?s:0}}class Se extends e.APIRequestCommand{constructor({limit:t,token:s,userIdsFilter:n,metaDataKeyFilter:r,metaDataValuesFilter:i,nicknameStartsWithFilter:o}){super(),this.method=e.APIRequestMethod.GET,this.path=e.API_PATH_USERS,this.params=e.deundefined({limit:t,token:s,user_ids:n,metadatakey:r,metadatavalues_in:i,nickname_startswith:o})}}class ve extends e.APIResponseCommand{constructor(t,s){super(t,s),this.users=s.users.map((s=>new e.User(t,s))),this.next=s.next}}class Pe extends e.BaseListQuery{constructor(e,t){var s,n,r;super(e,t),this.userIdsFilter=null,this.metaDataKeyFilter=null,this.metaDataValuesFilter=null,this.nicknameStartsWithFilter=null,this.userIdsFilter=null!==(s=t.userIdsFilter)&&void 0!==s?s:null,this.metaDataKeyFilter=null!==(n=t.metaDataKeyFilter)&&void 0!==n?n:null,this.metaDataValuesFilter=null!==(r=t.metaDataValuesFilter)&&void 0!==r?r:null,this.nicknameStartsWithFilter=t.nicknameStartsWithFilter||null}_validate(){return super._validate()&&e.isArrayOf("string",this.userIdsFilter,!0)&&e.isTypeOf("string",this.metaDataKeyFilter,!0)&&e.isArrayOf("string",this.metaDataValuesFilter,!0)&&e.isTypeOf("string",this.metaDataKeyFilter,!0)}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:t}=e.Vault.of(this._iid),s=new Se(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),n=yield t.send(s),{users:r,next:i}=n.as(ve);return this._token=i,this._hasNext=!!i,this._isLoading=!1,r}return[]}throw e.SendbirdError.invalidParameters}))}}class ye extends e.APIRequestCommand{constructor({userId:t,limit:s,token:n,userIdsFilter:r}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${t}/block`,this.params=e.deundefined({limit:s,token:n,user_ids:r})}}class Ce extends e.APIResponseCommand{constructor(t,s){super(t,s),this.users=s.users.map((s=>new e.User(t,s))),this.next=s.next}}class Te extends e.BaseListQuery{constructor(e,t){var s;super(e,t),this.userIdsFilter=null,this.userIdsFilter=null!==(s=t.userIdsFilter)&&void 0!==s?s:null}_validate(){return super._validate()&&e.isArrayOf("string",this.userIdsFilter,!0)}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new ye(e.undefineNullProps(Object.assign(Object.assign({},this),{userId:t.userId,token:this._token}))),r=yield s.send(n),{users:i,next:o}=r.as(Ce);return this._token=o,this._hasNext=!!o,this._isLoading=!1,i}return[]}throw e.SendbirdError.invalidParameters}))}}class Ae extends e.APIRequestCommand{constructor({userId:t,limit:s,token:n}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_USERS}/${encodeURIComponent(t)}/friends`,this.params={limit:s,token:n}}}class Ee extends e.APIResponseCommand{constructor(t,s){super(t,s),this.hasMore=s.has_more,this.users=s.users.map((s=>new e.User(t,s))),this.next=s.next}}class be extends e.BaseListQuery{_validate(){return super._validate()}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new Ae(Object.assign(Object.assign({},this),{userId:t.userId,token:this._token})),r=yield s.send(n),{users:i,hasMore:o,next:a}=r.as(Ee);return this._token=a,this._hasNext=o,this._isLoading=!1,i}return[]}throw e.SendbirdError.invalidParameters}))}}const we=6291456;class ke extends r.BaseStore{constructor(t){var{AsyncStorage:s,itemSizeLimit:n=we}=t,r=e.__rest(t,["AsyncStorage","itemSizeLimit"]);super(Object.assign(Object.assign({},r),{itemSizeLimit:n})),this._asyncStorage=s}_isBelonging(e){return e.startsWith(`${this.dbname}/`)}_getActualKey(e){return`${this.dbname}/${e}`}_getAllRawKeys(){return e.__awaiter(this,void 0,void 0,(function*(){return(yield this._asyncStorage.getAllKeys()).filter((e=>this._isBelonging(e))).map((e=>e.substring(`${this.dbname}/`.length)))}))}_getRaw(t){return e.__awaiter(this,void 0,void 0,(function*(){const e=yield this._asyncStorage.getItem(this._getActualKey(t));return e?JSON.parse(e):null}))}_setRaw(t){return e.__awaiter(this,void 0,void 0,(function*(){const e=[];for(const s of t){const{key:t,data:n}=s;n.length<=this.adjustedItemSizeLimit&&e.push([this._getActualKey(t),JSON.stringify(s)])}yield this._asyncStorage.multiSet(e)}))}_removeRaw(t){return e.__awaiter(this,void 0,void 0,(function*(){yield this._asyncStorage.multiRemove(t.map((e=>this._getActualKey(e))))}))}checkAvailability(){return e.__awaiter(this,void 0,void 0,(function*(){if(!this._asyncStorage)throw r.NestDBError.storeNotAvailable}))}init(t){return e.__awaiter(this,void 0,void 0,(function*(){this.dbname=t}))}clear(){return e.__awaiter(this,void 0,void 0,(function*(){const e=yield this.getAllKeys();yield this.removeMany(e)}))}}let Re;class Ue{constructor(t,s,n){this._storeInitialized=!1,this._iid=t,this.options=s;const{sdkState:i,cacheContext:o,dispatcher:a,sessionManager:d,requestQueue:u,logger:c,userEventHandlers:l,appStateToggleEnabled:h}=e.Vault.of(t);this._onlineDetector=new I({logger:c,connectionDelegate:{reconnect:()=>{const{sdkState:s,connectionManager:n,sessionManager:r}=e.Vault.of(t);r.auth.hasSession?"foreground"===s.appState&&n.resetAndReconnect():n.connect(r.auth.authToken)},disconnect:()=>{const{connectionManager:s}=e.Vault.of(t);s.disconnect()}}});const p=new r.AutoResendManager(t,{localCacheEnabled:o.localCacheEnabled,dispatcher:a,sdkState:i,logger:c});n.forEach((e=>{e.init(t,{sdkState:i,cacheContext:o,dispatcher:a,sessionManager:d,requestQueue:u,logger:c,onlineDetector:this._onlineDetector}),this[e.name]=e})),this._appStateChangeDetector=new g({isEnabled:h}),this._appStateChangeDetector.on("resume",(()=>{c.debug("the page resumes from freeze"),this.setForegroundState()})).on("pause",(()=>{c.debug("the page freezes"),this.setBackgroundState()})),a.on((s=>{if(s instanceof e.ConnectionStateChangeCommand){if(s.stateType===e.ConnectionStateType.CONNECTED)p.processNonAutoResendRegisteredPendingMessages()}else if(s instanceof e.WebSocketEventCommand)switch(s.code){case"USEV":{const{event:n}=s.as(r.UserEventCommand);switch(n.category){case r.UserEventCategory.FRIEND_DISCOVERED:{const{friendDiscoveries:s}=r.UserEvent.getDataAsFriendDiscoveredEvent(t,n);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return l.forEach((e=>{e.onFriendsDiscovered&&e.onFriendsDiscovered(s)}))}))));break}}break}}else if(s instanceof e.SubscribedUnreadMessageCountUpdateCommand){const{subscribedUnreadMessageCount:t}=e.Vault.of(this._iid);let n=!1;const r=s.ts;if("number"==typeof r&&r>t.ts){if(t.all!==s.all&&(n=!0),t.all=s.all>=0?s.all:0,s.customTypes)for(const e in s.customTypes)t.customTypes[e]!==s.customTypes[e]&&(n=!0),t.customTypes[e]=s.customTypes[e];n=n&&t.ts>0,t.ts=r}n&&e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return l.forEach((e=>{e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(t.all,t.customTypes)}))}))))}else s instanceof e.UserProfileUpdateCommand?o.preference.set(this._getUserProfileCacheKey(i.userId),e.UserProfile.payloadify(s.userProfile)):s instanceof e.SessionExpiredCommand&&s.error&&s.error.isSessionRevokedError&&(c.debug("session revoked."),this.disconnect())}))}static init(n){const{appId:i,appVersion:o,modules:a=[],options:d=new e.SendbirdChatOptions,debugMode:u=!1,customApiHost:c,customWebSocketHost:l,newInstance:h=!1,logLevel:p,localCacheEnabled:_=!1,localCacheConfig:m=new e.LocalCacheConfig,localCacheEncryption:f,useAsyncStorageStore:g=null,appStateToggleEnabled:I=!0}=n;if(!Re||h){const n=`su-${e.uuid()}`,h=null!=f?f:{encrypt:e=>e,decrypt:e=>e};let S=new r.MemoryStore({encryption:h});u||(S=e.isReactNative()?g?new ke({AsyncStorage:g,encryption:h}):new r.MemoryStore({encryption:h}):new r.IndexedDbStore({encryption:h})),new e.Vault(n,{appId:i,appVersion:o,options:d,apiHost:null!=c?c:`https://api-${i}.sendbird.com`,websocketHost:null!=l?l:`wss://ws-${i}.sendbird.com`,store:S,encryption:h,logLevel:p,localCacheEnabled:_,localCacheConfig:m,debugMode:u,appStateToggleEnabled:I});const v=[new t.MessageModule,new s.PollModule],P=new Ue(n,d,[...a,...v]);return Re||(Re=P),P}return Re}static get instance(){return Re}static get version(){return e.version}get appId(){const{sdkState:t}=e.Vault.of(this._iid);return t.appId}get appInfo(){const{appInfo:t}=e.Vault.of(this._iid);return null!=t?t:null}get appVersion(){var t;const{sdkState:s}=e.Vault.of(this._iid);return null!==(t=s.appVersion)&&void 0!==t?t:""}get debugMode(){const{debugMode:t}=e.Vault.of(this._iid);return!!t}get logLevel(){const{logger:t}=e.Vault.of(this._iid);return t.level}set logLevel(t){const{logger:s}=e.Vault.of(this._iid);s.level=t}get isCacheEnabled(){const{cacheContext:t}=e.Vault.of(this._iid);return t.localCacheEnabled}get localCacheConfig(){const{cacheContext:t}=e.Vault.of(this._iid);return t.localCacheEnabled?t.localCacheConfig:null}get ekey(){const{sessionManager:t}=e.Vault.of(this._iid);return t.ekey}get currentUser(){var t;const{sessionManager:s}=e.Vault.of(this._iid);return null!==(t=s.currentUser)&&void 0!==t?t:null}get connectionState(){const{connectionManager:t}=e.Vault.of(this._iid);return t.isConnected?e.ConnectionState.OPEN:t.isConnecting?e.ConnectionState.CONNECTING:e.ConnectionState.CLOSED}get lastConnectedAt(){const{connectedAt:t,connectionManager:s}=e.Vault.of(this._iid);return s.isConnected?t:0}get fcmPushToken(){var e;return null!==(e=this._fcmPushToken)&&void 0!==e?e:null}get apnsPushToken(){var e;return null!==(e=this._apnsPushToken)&&void 0!==e?e:null}_getCurrentPreferenceVersion(){return 1}_getPreferenceCacheKey(e){return`sendbird@${this.appId}/${e}.pref`}_getUserProfileCacheKey(e){return`sendbird@${this.appId}/${e}.profile`}getMemoryStoreForDebugging(){const{debugMode:t,cacheContext:s}=e.Vault.of(this._iid);if(t)return s.store instanceof r.MemoryStore?s.store:null;throw e.SendbirdError.debugModeRequired}addExtension(t,s){const{sdkState:n}=e.Vault.of(this._iid);["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(t)>-1&&n.extensions&&(n.extensions[t]=s)}setOnlineListener(e){this._onlineDetector.setOnlineListener(e)}setOfflineListener(e){this._onlineDetector.setOfflineListener(e)}_safeInitializeStore(t){return e.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:s}=e.Vault.of(this._iid);try{yield s.store.init(t),this._storeInitialized=!0}catch(e){s.replaceStore(new r.MemoryStore),yield this._safeInitializeStore(t)}}))}initializeCache(t){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,cacheContext:n,connectionManager:i,dispatcher:o,logger:a}=e.Vault.of(this._iid);if(!s.userId||s.userId!==t){yield i.logout();const d=`sendbird@${s.appId}/${t}.db`;if(n.localCacheEnabled)try{if(!n.nestdb||n.nestdb.state===r.NestDBState.CLOSED||n.nestdb.name!==d){const e=n.nestdb=new r.NestDB({name:`sendbird@${s.appId}/${t}.db`,version:2,store:n.store});e.on("upgrade",m(e,n.store)),e.on("storeReplaced",(t=>{n.replaceStore(t),n.localCacheEnabled=!1,e.on("upgrade",m(e,n.store))})),yield e.open(),this._storeInitialized=!0,o.dispatch(new r.DatabaseOpenCommand(this._iid,{userId:t}))}s.userId=t}catch(n){throw a.warn("Nest DB Open Failed. ",n),yield this._safeInitializeStore(d),s.userId=t,e.SendbirdError.databaseError}else yield this._safeInitializeStore(d),s.userId=t}}))}getCacheDataSize(){return e.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:t}=e.Vault.of(this._iid);return t.localCacheEnabled&&t.nestdb?yield t.nestdb.estimateUsage():0}))}clearCachedData(){return e.__awaiter(this,void 0,void 0,(function*(){const{cacheContext:t}=e.Vault.of(this._iid);t.localCacheEnabled&&t.nestdb&&(yield t.nestdb.clear()),this._storeInitialized&&(yield t.preference.clear())}))}clearCachedMessages(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isArrayOf("string",t)).throw(e.SendbirdError.invalidParameters);const s=r.MessageCache.of(this._iid),n=r.UnsentMessageCache.of(this._iid);s&&n&&(yield Promise.all(t.map((t=>e.__awaiter(this,void 0,void 0,(function*(){yield s.removeMessagesOfChannel(t),yield n.removeMessagesOfChannel(t)}))))))}))}connect(t,s){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)&&e.isTypeOf("string",s,!0)).throw(e.SendbirdError.invalidParameters);const{sdkState:n,cacheContext:i,connectionManager:o,statLogCollector:a}=e.Vault.of(this._iid);try{yield this.initializeCache(t);const{dispatcher:s}=e.Vault.of(this._iid);s.dispatch(new r.ReduceDBSizeEventCommand)}catch(t){const{logger:s}=e.Vault.of(this._iid);i.localCacheEnabled=!1,s.warn("Cache initialization failed - cache is not available.")}yield i.preference.init(this._getPreferenceCacheKey(t),this._getCurrentPreferenceVersion());const d=yield i.preference.get(this._getUserProfileCacheKey(t));if(d){new e.UserProfile(this._iid,d).apply()}yield a.init(`sendbird@${n.appId}/${t}.statlog`);try{yield o.connect(s)}finally{this._onlineDetector.start(),this._appStateChangeDetector.start()}return this.currentUser}))}reconnect(){const{connectionManager:t,sdkState:s,sessionManager:n}=e.Vault.of(this._iid),r=n.auth.hasSession;return r&&(this._appStateChangeDetector.start(),this._onlineDetector.start(),t.resetAndReconnect().then((()=>{s.appState="foreground"})).catch((()=>{}))),r}disconnect(){return e.__awaiter(this,void 0,void 0,(function*(){const{connectionManager:t,requestQueue:s}=e.Vault.of(this._iid);this._appStateChangeDetector.stop(),this._onlineDetector.stop(),s.cancelAll(),yield t.logout(),yield this.clearCachedData()}))}disconnectWebSocket(){return e.__awaiter(this,void 0,void 0,(function*(){const{connectionManager:t,requestQueue:s}=e.Vault.of(this._iid);this._appStateChangeDetector.stop(),this._onlineDetector.stop(),s.cancelAll(),yield t.disconnectWebSocket()}))}setBackgroundState(){const{connectionManager:t,sdkState:s,logger:n}=e.Vault.of(this._iid);"foreground"===s.appState&&(s.appState="background",n.debug("going background state"),t.background())}setForegroundState(){const{connectionManager:t,sdkState:s,logger:n}=e.Vault.of(this._iid);"background"===s.appState&&(s.appState="foreground",n.debug("going foreground state"),t.resetAndReconnect())}setSessionHandler(t){e.unless(t instanceof c).throw(e.SendbirdError.invalidParameters);const{sessionManager:s}=e.Vault.of(this._iid);s.handler=t}addUserEventHandler(t,s){e.unless(e.isTypeOf("string",t)&&s instanceof _).throw(e.SendbirdError.invalidParameters);const{userEventHandlers:n}=e.Vault.of(this._iid);n.set(t,s)}removeUserEventHandler(t){const{userEventHandlers:s}=e.Vault.of(this._iid);s.delete(t)}removeAllUserEventHandler(){const{userEventHandlers:t}=e.Vault.of(this._iid);t.clear()}addConnectionHandler(t,s){e.unless(e.isTypeOf("string",t)&&s instanceof h).throw(e.SendbirdError.invalidParameters);const{connectionHandlers:n}=e.Vault.of(this._iid);n.set(t,s)}removeConnectionHandler(t){const{connectionHandlers:s}=e.Vault.of(this._iid);s.delete(t)}removeAllConnectionHandler(){const{connectionHandlers:t}=e.Vault.of(this._iid);t.clear()}createApplicationUserListQuery(e={}){return new Pe(this._iid,e)}createBlockedUserListQuery(e={}){return new Te(this._iid,e)}createFriendListQuery(e={}){return new be(this._iid,e)}createMessageSearchQuery(e){return new i.MessageSearchQuery(this._iid,e)}createPollListQuery(e){return new o.PollListQuery(this._iid,Object.assign({},e))}createPollVoterListQuery(e){return new o.PollVoterListQuery(this._iid,Object.assign({},e))}buildUserFromSerializedData(t){const s=e.deserialize(t);return new e.User(this._iid,e.User.payloadify(s))}updateCurrentUserInfo(t={}){return e.__awaiter(this,void 0,void 0,(function*(){const s=Object.assign(Object.assign({},d),t);if(e.unless((t=>e.isFile(t.profileImage,!0)&&e.isTypeOf("string",t.profileUrl,!0)&&e.isTypeOf("string",t.nickname,!0))(s)).throw(e.SendbirdError.invalidParameters),this.currentUser){const{sdkState:t,requestQueue:n}=e.Vault.of(this._iid),r=new S(Object.assign({userId:t.userId},s)),i=yield n.send(r),{user:o}=i.as(v);return this.currentUser&&(s.nickname&&(this.currentUser.nickname=o.nickname),(s.profileUrl||s.profileImage)&&(this.currentUser.plainProfileUrl=o.profileUrl)),o}throw e.SendbirdError.connectionRequired}))}updateCurrentUserInfoWithPreferredLanguages(t){return e.__awaiter(this,void 0,void 0,(function*(){if(e.unless(e.isArrayOf("string",t)).throw(e.SendbirdError.invalidParameters),this.currentUser){const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new S({userId:s.userId,preferredLanguages:t}),i=yield n.send(r),{user:o}=i.as(v);return this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),o}throw e.SendbirdError.connectionRequired}))}registerFCMPushTokenForCurrentUser(t){return e.__awaiter(this,void 0,void 0,(function*(){if(e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),!this.currentUser)return this._fcmPushToken=t,e.PushTokenRegistrationState.PENDING;try{const{sessionManager:s,sdkState:n,requestQueue:r}=e.Vault.of(this._iid);if(s.hasDeviceToken(e.PushTokenType.FCM,t))return e.PushTokenRegistrationState.SUCCESS;const i=new y({userId:n.userId,token:t});return yield r.send(i),yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){s.setDeviceToken(e.PushTokenType.FCM,t),yield s.saveDeviceToken()})))),this._fcmPushToken="",e.PushTokenRegistrationState.SUCCESS}catch(t){return e.PushTokenRegistrationState.ERROR}}))}unregisterFCMPushTokenForCurrentUser(t){return e.__awaiter(this,void 0,void 0,(function*(){if(e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),!this.currentUser)return this._fcmPushToken=t,e.PushTokenRegistrationState.PENDING;try{const{sessionManager:s,sdkState:n,requestQueue:r}=e.Vault.of(this._iid),i=new T({userId:n.userId,token:t}),{lastDeletedAt:o}=yield r.send(i);return yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){s.unsetDeviceToken(e.PushTokenType.FCM,t),s.setDeviceTokenDeletedAt(o),yield s.saveDeviceToken()})))),this._fcmPushToken="",e.PushTokenRegistrationState.SUCCESS}catch(t){return e.PushTokenRegistrationState.ERROR}}))}unregisterFCMPushTokenAllForCurrentUser(){return e.__awaiter(this,void 0,void 0,(function*(){if(this.currentUser){const{sessionManager:t,sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new E({userId:s.userId}),{lastDeletedAt:i}=yield n.send(r);yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){t.unsetDeviceTokens(e.PushTokenType.FCM),t.setDeviceTokenDeletedAt(i),yield t.saveDeviceToken()}))))}}))}registerAPNSPushTokenForCurrentUser(t){return e.__awaiter(this,void 0,void 0,(function*(){if(e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),!this.currentUser)return this._apnsPushToken=t,e.PushTokenRegistrationState.PENDING;try{const{sessionManager:s,sdkState:n,requestQueue:r}=e.Vault.of(this._iid);if(s.hasDeviceToken(e.PushTokenType.APNS,t))return e.PushTokenRegistrationState.SUCCESS;const i=new P({userId:n.userId,token:t});return yield r.send(i),yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){s.setDeviceToken(e.PushTokenType.APNS,t),yield s.saveDeviceToken()})))),this._apnsPushToken="",e.PushTokenRegistrationState.SUCCESS}catch(t){return e.PushTokenRegistrationState.ERROR}}))}unregisterAPNSPushTokenForCurrentUser(t){return e.__awaiter(this,void 0,void 0,(function*(){if(e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters),!this.currentUser)return this._apnsPushToken=t,e.PushTokenRegistrationState.PENDING;try{const{sessionManager:s,sdkState:n,requestQueue:r}=e.Vault.of(this._iid),i=new C({userId:n.userId,token:t}),{lastDeletedAt:o}=yield r.send(i);return yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){s.unsetDeviceToken(e.PushTokenType.APNS,t),s.setDeviceTokenDeletedAt(o),yield s.saveDeviceToken()})))),this._apnsPushToken="",e.PushTokenRegistrationState.SUCCESS}catch(t){return e.PushTokenRegistrationState.ERROR}}))}unregisterAPNSPushTokenAllForCurrentUser(){return e.__awaiter(this,void 0,void 0,(function*(){if(this.currentUser){const{sessionManager:t,sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new A({userId:s.userId}),{lastDeletedAt:i}=yield n.send(r);yield e.runOrNothing((()=>e.__awaiter(this,void 0,void 0,(function*(){t.unsetDeviceTokens(e.PushTokenType.APNS),t.setDeviceTokenDeletedAt(i),yield t.saveDeviceToken()}))))}}))}getChannelInvitationPreference(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new k({userId:t.userId}),r=yield s.send(n),{autoAccept:i}=r.as(R);return{autoAccept:i}}))}setChannelInvitationPreference(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("boolean",t)).throw(e.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new U({userId:s.userId,willAutoAccept:t}),i=yield n.send(r),{autoAccept:o}=i.as(O);return{autoAccept:o}}))}getDoNotDisturb(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new x({userId:t.userId}),r=yield s.send(n),{preference:i}=r.as(M);return i}))}setDoNotDisturb(t,s=0,n=0,r=0,i=0,o=""){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("boolean",t)&&e.isTypeOf("number",s)&&e.isTypeOf("number",n)&&e.isTypeOf("number",r)&&e.isTypeOf("number",i)&&e.isTypeOf("string",o)).throw(e.SendbirdError.invalidParameters);const{sdkState:a,requestQueue:d}=e.Vault.of(this._iid),u=new D({userId:a.userId,doNotDisturbOn:t,startHour:s,startMin:n,endHour:r,endMin:i,timezone:o}),c=yield d.send(u),{preference:l}=c.as(q);return l}))}getSnoozePeriod(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new L({userId:t.userId}),r=yield s.send(n),{snoozePeriod:i}=r.as(N);return i}))}setSnoozePeriod(t,s=0,n=0){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("boolean",t)&&e.isTypeOf("number",s)&&e.isTypeOf("number",n)).throw(e.SendbirdError.invalidParameters);const{sdkState:r,requestQueue:i}=e.Vault.of(this._iid),o=new V({userId:r.userId,snoozeOn:t,startTs:s,endTs:n}),a=yield i.send(o),{snoozePeriod:d}=a.as($);return d}))}getMyPushTokensByToken(t,s){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)&&e.isEnumOf(e.PushTokenType,s)).throw(e.SendbirdError.invalidParameters);const{sdkState:n,requestQueue:r,sessionManager:i}=e.Vault.of(this._iid),o=new b({userId:n.userId,type:s,token:t}),a=yield r.send(o),{pushTokens:d}=a.as(w);for(const e of d.deviceTokens)i.setDeviceToken(d.type,e);return yield i.saveDeviceToken(),d}))}getPushTriggerOption(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new Q({userId:t.userId});return(yield s.send(n)).as(j).pushTriggerOption}))}setPushTriggerOption(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isEnumOf(e.PushTriggerOption,t)).throw(e.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new z({userId:s.userId,pushTriggerOption:t});return(yield n.send(r)).as(G).pushTriggerOption}))}getPushTemplate(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new B({userId:t.userId});return(yield s.send(n)).as(K).name}))}setPushTemplate(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isEnumOf(e.PushTemplate,t)).throw(e.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new W({userId:s.userId,templateName:t});return(yield n.send(r)).as(J).name}))}blockUser(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(t instanceof e.User||e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new H({userId:s.userId,blockedUserId:t instanceof e.User?t.userId:t});yield n.send(r)}))}blockUserWithUserId(t){return e.__awaiter(this,void 0,void 0,(function*(){return this.blockUser(t)}))}unblockUser(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(t instanceof e.User||e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new F({userId:s.userId,unblockedUserId:t instanceof e.User?t.userId:t});yield n.send(r)}))}unblockUserWithUserId(t){return e.__awaiter(this,void 0,void 0,(function*(){return this.unblockUser(t)}))}getFriendChangeLogsByToken(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new Y({userId:s.userId,token:t}),i=yield n.send(r),{changelogs:o}=i.as(X);return o}))}getAllowFriendDiscovery(){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:t,requestQueue:s}=e.Vault.of(this._iid),n=new ie({userId:t.userId}),r=yield s.send(n),{allowFriendDiscovery:i}=r.as(oe);return i}))}setAllowFriendDiscovery(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("boolean",t)).throw(e.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new ae({userId:s.userId,allowFriendDiscovery:t});return yield n.send(r),t}))}uploadFriendDiscoveries(t){return e.__awaiter(this,void 0,void 0,(function*(){const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new Z({userId:s.userId,discoveries:t}),i=yield n.send(r),{friendDiscoveryRequestId:o}=i.as(ee);return o}))}deleteFriendDiscovery(t){return e.__awaiter(this,void 0,void 0,(function*(){return this.deleteFriendDiscoveries([t])}))}deleteFriendDiscoveries(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isArrayOf("string",t)).throw(e.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new te({userId:s.userId,discoveryKeys:t});yield n.send(r)}))}addFriends(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isArrayOf("string",t)).throw(e.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new se({userId:s.userId,userIds:t}),i=yield n.send(r),{users:o}=i.as(ne);return o}))}deleteFriend(t){return e.__awaiter(this,void 0,void 0,(function*(){return this.deleteFriends([t])}))}deleteFriends(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isArrayOf("string",t)).throw(e.SendbirdError.invalidParameters);const{sdkState:s,requestQueue:n}=e.Vault.of(this._iid),r=new re({userId:s.userId,userIds:t});yield n.send(r)}))}getAllEmoji(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:t}=e.Vault.of(this._iid),s=new le,n=yield t.send(s),{emojiContainer:r}=n.as(he);return r}))}getEmojiCategory(t){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=e.Vault.of(this._iid),n=new pe({categoryId:t}),r=yield s.send(n),{emojiCategory:i}=r.as(_e);return i}))}getEmoji(t){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:s}=e.Vault.of(this._iid),n=new me({key:t}),r=yield s.send(n),{emoji:i}=r.as(fe);return i}))}getUIKitConfiguration(){return e.__awaiter(this,void 0,void 0,(function*(){const t=e.Vault.of(this._iid);e.unless(t.hasExtension("sb_uikit")).throw(e.SendbirdError.notSupportedError);const{requestQueue:s}=t,n=new ge,r=yield s.send(n),{uikitConfiguration:i}=r.as(Ie);return i}))}}exports.CachedChannelInfo=e.CachedChannelInfo,Object.defineProperty(exports,"ChannelType",{enumerable:!0,get:function(){return e.ChannelType}}),Object.defineProperty(exports,"ConnectionState",{enumerable:!0,get:function(){return e.ConnectionState}}),exports.LocalCacheConfig=e.LocalCacheConfig,Object.defineProperty(exports,"LogLevel",{enumerable:!0,get:function(){return e.LogLevel}}),Object.defineProperty(exports,"PushTemplate",{enumerable:!0,get:function(){return e.PushTemplate}}),Object.defineProperty(exports,"PushTokenRegistrationState",{enumerable:!0,get:function(){return e.PushTokenRegistrationState}}),Object.defineProperty(exports,"PushTokenType",{enumerable:!0,get:function(){return e.PushTokenType}}),Object.defineProperty(exports,"PushTriggerOption",{enumerable:!0,get:function(){return e.PushTriggerOption}}),Object.defineProperty(exports,"Role",{enumerable:!0,get:function(){return e.Role}}),exports.SendbirdChatOptions=e.SendbirdChatOptions,exports.SendbirdError=e.SendbirdError,exports.UIKitConfigInfo=e.UIKitConfigInfo,exports.User=e.User,Object.defineProperty(exports,"UserOnlineState",{enumerable:!0,get:function(){return e.UserOnlineState}}),exports.BannedUserListQuery=n.BannedUserListQuery,exports.BaseChannel=n.BaseChannel,exports.MutedUserListQuery=n.MutedUserListQuery,exports.OperatorListQuery=n.OperatorListQuery,Object.defineProperty(exports,"ReportCategory",{enumerable:!0,get:function(){return n.ReportCategory}}),exports.RestrictedUser=n.RestrictedUser,exports.RestrictionInfo=n.RestrictionInfo,Object.defineProperty(exports,"RestrictionType",{enumerable:!0,get:function(){return n.RestrictionType}}),exports.MemoryStore=r.MemoryStore,exports.Plugin=i.Plugin,exports.Participant=a.Participant,exports.ApplicationUserListQuery=Pe,exports.BlockedUserListQuery=Te,exports.ConnectionHandler=h,exports.Emoji=de,exports.EmojiCategory=ue,exports.EmojiContainer=ce,exports.FriendListQuery=be,exports.SessionHandler=c,exports.UserEventHandler=_,exports.default=Ue; diff --git a/cjs/lib/__bundle-032c97c6.js b/cjs/lib/__bundle-032c97c6.js new file mode 100644 index 0000000..df75bdf --- /dev/null +++ b/cjs/lib/__bundle-032c97c6.js @@ -0,0 +1,2 @@ +"use strict";function e(e,t,s,i){return new(s||(s=Promise))((function(n,o){function r(e){try{l(i.next(e))}catch(e){o(e)}}function a(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(r,a)}l((i=i.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var t,s="4.9.4-rc.1";class i{static get OS_VERSION(){return"undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.replace(/,/g,"."):"noAgent"}static get SDK_VERSION(){return s}static get SDK_MAJOR_VERSION(){return i.SDK_VERSION.split(".")[0]}static get DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL(){return 100}static get INTERNAL_CALL(){return"ic"}}exports.SendbirdErrorCode=void 0,(t=exports.SendbirdErrorCode||(exports.SendbirdErrorCode={}))[t.STAT_LOG_NOT_ALLOWED=400108]="STAT_LOG_NOT_ALLOWED",t[t.NON_AUTHORIZED=400108]="NON_AUTHORIZED",t[t.INVALID_TOKEN=400111]="INVALID_TOKEN",t[t.NOT_FOUND_IN_DATABASE=400201]="NOT_FOUND_IN_DATABASE",t[t.SESSION_TOKEN_EXPIRED=400302]="SESSION_TOKEN_EXPIRED",t[t.SESSION_KEY_EXPIRED=400309]="SESSION_KEY_EXPIRED",t[t.SESSION_REVOKED=400310]="SESSION_REVOKED",t[t.STAT_UPLOAD_NOT_ALLOWED=403200]="STAT_UPLOAD_NOT_ALLOWED",t[t.INTERNAL_SERVER_ERROR=500901]="INTERNAL_SERVER_ERROR",t[t.RATE_LIMIT_EXCEEDED=500910]="RATE_LIMIT_EXCEEDED",t[t.UNKNOWN_SERVER_ERROR=900200]="UNKNOWN_SERVER_ERROR",t[t.DEBUG_MODE_REQUIRED=7e5]="DEBUG_MODE_REQUIRED",t[t.LOST_INSTANCE=700100]="LOST_INSTANCE",t[t.CONNECTION_RENEW=700102]="CONNECTION_RENEW",t[t.INVALID_CONNECTION_STATE_TRANSITION=700200]="INVALID_CONNECTION_STATE_TRANSITION",t[t.INVALID_COMMAND=700700]="INVALID_COMMAND",t[t.UNKNOWN_ERROR=77e4]="UNKNOWN_ERROR",t[t.INVALID_INITIALIZATION=800100]="INVALID_INITIALIZATION",t[t.CONNECTION_REQUIRED=800101]="CONNECTION_REQUIRED",t[t.CONNECTION_CANCELED=800102]="CONNECTION_CANCELED",t[t.INVALID_PARAMETER=800110]="INVALID_PARAMETER",t[t.NOT_SUPPORTED_ERROR=800111]="NOT_SUPPORTED_ERROR",t[t.NETWORK_ERROR=800120]="NETWORK_ERROR",t[t.NETWORK_ROUTING_ERROR=800121]="NETWORK_ROUTING_ERROR",t[t.MALFORMED_DATA=800130]="MALFORMED_DATA",t[t.MALFORMED_ERROR_DATA=800140]="MALFORMED_ERROR_DATA",t[t.WRONG_CHANNEL_TYPE=800150]="WRONG_CHANNEL_TYPE",t[t.MARK_AS_READ_RATE_LIMIT_EXCEEDED=800160]="MARK_AS_READ_RATE_LIMIT_EXCEEDED",t[t.QUERY_IN_PROGRESS=800170]="QUERY_IN_PROGRESS",t[t.ACK_TIMEOUT=800180]="ACK_TIMEOUT",t[t.LOGIN_TIMEOUT=800190]="LOGIN_TIMEOUT",t[t.WEBSOCKET_CONNECTION_CLOSED=800200]="WEBSOCKET_CONNECTION_CLOSED",t[t.WEBSOCKET_CONNECTION_FAILED=800210]="WEBSOCKET_CONNECTION_FAILED",t[t.REQUEST_FAILED=800220]="REQUEST_FAILED",t[t.FILE_UPLOAD_CANCEL_FAILED=800230]="FILE_UPLOAD_CANCEL_FAILED",t[t.REQUEST_CANCELED=800240]="REQUEST_CANCELED",t[t.REQUEST_DUPLICATED=800250]="REQUEST_DUPLICATED",t[t.FILE_SIZE_LIMIT_EXCEEDED=800260]="FILE_SIZE_LIMIT_EXCEEDED",t[t.SESSION_TOKEN_REQUEST_FAILED=800500]="SESSION_TOKEN_REQUEST_FAILED",t[t.SESSION_TOKEN_REFRESHED=800501]="SESSION_TOKEN_REFRESHED",t[t.SESSION_TOKEN_REFRESH_FAILED=800502]="SESSION_TOKEN_REFRESH_FAILED",t[t.COLLECTION_DISPOSED=800600]="COLLECTION_DISPOSED",t[t.DATABASE_ERROR=800700]="DATABASE_ERROR";const n=e=>!(e instanceof o&&!e.shouldThrowOutside);class o extends Error{constructor({code:e=0,message:t=""}){super(t),this.shouldThrowOutside=!1,this.name="SendbirdError",this.code=e,Object.setPrototypeOf(this,o.prototype)}get isInvalidTokenError(){return this.code===exports.SendbirdErrorCode.INVALID_TOKEN}get isSessionTokenExpiredError(){return this.code===exports.SendbirdErrorCode.SESSION_TOKEN_EXPIRED}get isSessionKeyExpiredError(){return this.code===exports.SendbirdErrorCode.SESSION_KEY_EXPIRED}get isSessionRevokedError(){return this.code===exports.SendbirdErrorCode.SESSION_REVOKED}static get debugModeRequired(){return new o({code:exports.SendbirdErrorCode.DEBUG_MODE_REQUIRED,message:"Cannot run this operation in production mode."})}static get lostInstance(){return new o({code:exports.SendbirdErrorCode.LOST_INSTANCE,message:"Instance ID is missing. It should belong to an instance."})}static get invalidCommand(){return new o({code:exports.SendbirdErrorCode.INVALID_COMMAND,message:"Cannot send invalid command."})}static get unknown(){return new o({code:exports.SendbirdErrorCode.UNKNOWN_ERROR,message:"Unknown error occurred."})}static get connectionRenew(){return new o({code:exports.SendbirdErrorCode.CONNECTION_RENEW,message:"Connection restarts."})}static get invalidConnectionStateTransition(){return new o({code:exports.SendbirdErrorCode.INVALID_CONNECTION_STATE_TRANSITION,message:"Invalid connection state transition."})}static get connectionRequired(){return new o({code:exports.SendbirdErrorCode.CONNECTION_REQUIRED,message:"Connection is required."})}static get connectionCanceled(){return new o({code:exports.SendbirdErrorCode.CONNECTION_CANCELED,message:"Connection is canceled."})}static get invalidParameters(){return new o({code:exports.SendbirdErrorCode.INVALID_PARAMETER,message:"Invalid parameters."})}static get notSupportedError(){return new o({code:exports.SendbirdErrorCode.NOT_SUPPORTED_ERROR,message:"Given parameters are not supported."})}static get networkError(){return new o({code:exports.SendbirdErrorCode.NETWORK_ERROR,message:"There was a network error."})}static get markAsReadAllRateLimitExceeded(){return new o({code:exports.SendbirdErrorCode.MARK_AS_READ_RATE_LIMIT_EXCEEDED,message:"markAsRead rate limit exceeded."})}static get queryInProgress(){return new o({code:exports.SendbirdErrorCode.QUERY_IN_PROGRESS,message:"Query in progress."})}static get noAckTimeout(){return new o({code:exports.SendbirdErrorCode.ACK_TIMEOUT,message:"Command received no ack."})}static get loginTimeout(){return new o({code:exports.SendbirdErrorCode.LOGIN_TIMEOUT,message:"Connection timeout."})}static get connectionClosed(){return new o({code:exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,message:"Connection is closed. Please reconnect."})}static get requestFailed(){return new o({code:exports.SendbirdErrorCode.REQUEST_FAILED,message:"Request failed."})}static get fileUploadCanceled(){return new o({code:exports.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED,message:"File upload has been canceled."})}static get requestCanceled(){return new o({code:exports.SendbirdErrorCode.REQUEST_CANCELED,message:"Request has been canceled."})}static get sessionTokenRefreshFailed(){return new o({code:exports.SendbirdErrorCode.SESSION_TOKEN_REFRESH_FAILED,message:"Failed to refresh the session key."})}static get sessionTokenRequestFailed(){return new o({code:exports.SendbirdErrorCode.SESSION_TOKEN_REQUEST_FAILED,message:"Failed to get the session token."})}static get databaseError(){return new o({code:exports.SendbirdErrorCode.DATABASE_ERROR,message:"Database error."})}static get fileSizeLimitExceededError(){return new o({code:exports.SendbirdErrorCode.FILE_SIZE_LIMIT_EXCEEDED,message:"File size exceeds the file size limit."})}throwOutside(){throw this.shouldThrowOutside=!0,this}}const r=[exports.SendbirdErrorCode.CONNECTION_REQUIRED,exports.SendbirdErrorCode.NETWORK_ERROR,exports.SendbirdErrorCode.ACK_TIMEOUT,exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_FAILED,exports.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED,exports.SendbirdErrorCode.REQUEST_CANCELED,exports.SendbirdErrorCode.INTERNAL_SERVER_ERROR,exports.SendbirdErrorCode.RATE_LIMIT_EXCEEDED,exports.SendbirdErrorCode.UNKNOWN_SERVER_ERROR],a=[exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_CLOSED,exports.SendbirdErrorCode.WEBSOCKET_CONNECTION_FAILED,exports.SendbirdErrorCode.CONNECTION_REQUIRED],l=(e,t,s=!1)=>!(!s||null!=t)||("string"!=typeof e?"object"==typeof e?d(e,t):c(e,t):typeof t===e),d=(e,t,s=!1)=>!(!s||null!=t)||Object.values(e).includes(t),c=(e,t)=>t instanceof e,h=(e,t,s=!1)=>!(!s||null!=t)||Array.isArray(t)&&t.every((t=>l(e,t))),u=(e,t=!1)=>{if(t&&null==e)return!0;const s="object"==typeof e&&null!==e&&e.hasOwnProperty("name")&&"string"==typeof e.name&&e.hasOwnProperty("uri")&&"string"==typeof e.uri&&e.hasOwnProperty("type")&&"string"==typeof e.type;if(!s){if("undefined"!=typeof Blob)return e instanceof Blob;if("undefined"!=typeof File)return e instanceof File}return s};class _{constructor({useMemberInfoInMessage:e=!0,typingIndicatorInvalidateTime:t=1e4,typingIndicatorThrottle:s=1e3,websocketResponseTimeout:i=1e4,websocketPayloadDecompression:n=!0,sessionTokenRefreshTimeout:o=60}={}){this._useMemberInfoInMessage=!0,this._typingIndicatorInvalidateTime=1e4,this._typingIndicatorThrottle=1e3,this._websocketResponseTimeout=1e4,this._sessionTokenRefreshTimeout=60,this._useMemberInfoInMessage=e,this._typingIndicatorInvalidateTime=t,this._typingIndicatorThrottle=s,this._websocketResponseTimeout=i,this._sessionTokenRefreshTimeout=o,this.websocketPayloadDecompression=n}get useMemberInfoInMessage(){return this._useMemberInfoInMessage}set useMemberInfoInMessage(e){l("boolean",e)&&(this._useMemberInfoInMessage=e)}get typingIndicatorInvalidateTime(){return this._typingIndicatorInvalidateTime}set typingIndicatorInvalidateTime(e){l("number",e)&&(this._typingIndicatorInvalidateTime=e)}get typingIndicatorThrottle(){return this._typingIndicatorThrottle}set typingIndicatorThrottle(e){l("number",e)&&e>=1e3&&e<=9e3&&(this._typingIndicatorThrottle=e)}get websocketResponseTimeout(){return this._websocketResponseTimeout}set websocketResponseTimeout(e){l("number",e)&&e>=5e3&&e<=3e4&&(this._websocketResponseTimeout=e)}get sessionTokenRefreshTimeout(){return this._sessionTokenRefreshTimeout}set sessionTokenRefreshTimeout(e){l("number",e)&&(e<60?e=60:e>1800&&(e=1800),this._sessionTokenRefreshTimeout=e)}}const p={encrypt:e=>e,decrypt:e=>e};class g{constructor({store:e}){this._preference=new Map,this._store=e}_savePreferenceKeys(){return e(this,void 0,void 0,(function*(){yield this._store.set({key:this._keysAddress,value:[...this._preference.keys()]})}))}init(t,s=1){var i;return e(this,void 0,void 0,(function*(){this._version=s,this._keysAddress=t;const e=`${t}.metadata.version`,n=yield this._store.get(e),o=null!==(i=yield this._store.get(t))&&void 0!==i?i:[];if(!n||n.versione.channel.messageCollectionLastAccessedAt===t.channel.messageCollectionLastAccessedAt?e.channel.lastMessage&&!t.channel.lastMessage?1:!e.channel.lastMessage&&t.channel.lastMessage?-1:e.channel.lastMessage||t.channel.lastMessage?e.channel.lastMessage.createdAt-t.channel.lastMessage.createdAt:0:e.channel.messageCollectionLastAccessedAt>t.channel.messageCollectionLastAccessedAt?1:-1,this._maxSize=Math.max(e,64),s?(this._clearOrder=t,this._customClearOrderComparator=s):this._clearOrder=y.MESSAGE_COLLECTION_ACCESSED_AT}get maxSize(){return this._maxSize}get clearOrder(){return this._clearOrder}get clearOrderComparator(){var e;return this._clearOrder===y.MESSAGE_COLLECTION_ACCESSED_AT?this._clearOrderComparatorUseMessageCollectionAccessedAt:null!==(e=this._customClearOrderComparator)&&void 0!==e?e:this._clearOrderComparatorUseMessageCollectionAccessedAt}}class b{get hasSession(){return!!this.sessionKey}clear(){this.authToken=void 0,this.sessionKey=void 0}}const C=()=>{let e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(t=>{const s=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?s:3&s|8).toString(16)}))};class T{constructor({container:e}){this._container={},this._container=e,this.key=C()}_register(e,t,s){var i;return e in this._container||(this._container[e]=new Map),null===(i=this._container[e])||void 0===i||i.set(this.key,{occurence:t,handler:s}),this}on(e,t){return this._register(e,-1,t)}once(e,t){return this._register(e,1,t)}close(){var e;for(const t in this._container)null===(e=this._container[t])||void 0===e||e.delete(this.key)}}class k{constructor(){this._container={}}on(e,t){return new T({container:this._container}).on(e,t)}once(e,t){return new T({container:this._container}).once(e,t)}dispatch(e,t){const s=this._container[e];if(s){const e=[];for(const i of s.keys()){const n=s.get(i);n.handler(t),n.occurence>0&&(n.occurence--,0===n.occurence&&e.push(i))}e.forEach((e=>s.delete(e)))}}}class x{constructor(){this._dispatcher=new k}on(e){return this._dispatcher.on("event",e)}once(e){return this._dispatcher.once("event",e)}dispatch(e){this._dispatcher.dispatch("event",e)}}class A{}const N=e=>{const t={};return e&&Object.keys(e).forEach((s=>{void 0===e[s]||Number.isNaN(e[s])||null===e[s]||(t[s]=e[s])})),t},I=e=>{if(null!=e){if("object"==typeof e){if(Array.isArray(e)){const t=[...e];for(const e in t)t[e]=I(t[e]);return t}for(const t in e)null===e[t]&&delete e[t];return e}return e}};var R,O,D,L,M,U,P,z,F;exports.ChannelType=void 0,(R=exports.ChannelType||(exports.ChannelType={})).BASE="base",R.GROUP="group",R.OPEN="open",exports.Role=void 0,(O=exports.Role||(exports.Role={})).OPERATOR="operator",O.NONE="none",exports.MessageType=void 0,(D=exports.MessageType||(exports.MessageType={})).BASE="base",D.USER="user",D.FILE="file",D.ADMIN="admin",exports.MessageTypeFilter=void 0,(L=exports.MessageTypeFilter||(exports.MessageTypeFilter={})).ALL="",L.USER="MESG",L.FILE="FILE",L.ADMIN="ADMM",exports.ServerSideMessageType=void 0,(M=exports.ServerSideMessageType||(exports.ServerSideMessageType={})).USER="MESG",M.FILE="FILE",M.ADMIN="ADMM",exports.MentionType=void 0,(U=exports.MentionType||(exports.MentionType={})).USERS="users",U.CHANNEL="channel",exports.ReplyType=void 0,(P=exports.ReplyType||(exports.ReplyType={})).ALL="all",P.NONE="none",P.ONLY_REPLY_TO_CHANNEL="only_reply_to_channel",exports.PushNotificationDeliveryOption=void 0,(z=exports.PushNotificationDeliveryOption||(exports.PushNotificationDeliveryOption={})).DEFAULT="default",z.SUPPRESS="suppress",exports.SendingStatus=void 0,(F=exports.SendingStatus||(exports.SendingStatus={})).PENDING="pending",F.SCHEDULED="scheduled",F.SUCCEEDED="succeeded",F.FAILED="failed",F.CANCELED="canceled";const q="v3",G=`/${q}/users`,K=`/${q}/storage/file`,B=`/${q}/group_channels`,H=`/${q}/sdk/group_channels`,V=`/${q}/open_channels`,j=`/${q}/sdk/open_channels`,$=`/${q}/search`,Z=`/${q}/report`,W=`/${q}/emojis`,Q=`/${q}/emoji_categories`,Y=`/${q}/polls`,X=`/${q}/scheduled_messages`,J=`/${q}/sdk/ui_kit/configuration`,ee=`/${q}/sdk/statistics`,te=(e,t,s)=>{switch(e){case exports.MentionType.CHANNEL:return!0;case exports.MentionType.USERS:if(t)for(const e of t)if(e===s)return!0}return!1},se=(e,t,s)=>{var i;let n=t||new FormData;for(const t in e){if(!Object.prototype.hasOwnProperty.call(e,t))continue;const o=e[t],r=s?`${s}[${t}]`:t;u(o)?n.append(r,o,null!==(i=o.name)&&void 0!==i?i:"filename"):"object"!=typeof o||null===o||Array.isArray(o)||o instanceof Blob?n.append(r,String(o)):n=se(o,n,r)}return n};var ie,ne;exports.APIRequestMethod=void 0,(ie=exports.APIRequestMethod||(exports.APIRequestMethod={})).GET="GET",ie.POST="POST",ie.PUT="PUT",ie.DELETE="DELETE";class oe extends A{constructor(){super(...arguments),this.params={},this.requireAuth=!0,this.headers={},this.requestId=C()}encodeParams(e){return null==e||""===e?encodeURIComponent(""):Array.isArray(e)?e.map((e=>this.encodeParams(e))).join(","):"object"==typeof e?encodeURIComponent(JSON.stringify(e)):encodeURIComponent(String(e))}get query(){const e=N(this.params);return`?${Object.keys(e).map((t=>`${encodeURIComponent(t)}=${this.encodeParams(e[t])}`)).join("&")}`}get payload(){const e=N(this.params);return Object.keys(e).some((t=>u(e[t])))?se(e):JSON.stringify(e)}}class re extends A{constructor(e,t){super(),this._iid=e,this._payload=t}get payload(){return Object.assign({},this._payload)}as(e){return new e(this._iid,this.payload)}}class ae extends A{constructor(e){super(),this.requestId=e}}class le extends A{constructor({expires_in:e,reason:t=exports.SendbirdErrorCode.SESSION_KEY_EXPIRED}){switch(super(),this.expiresIn=null!=e?e:0,t){case exports.SendbirdErrorCode.SESSION_KEY_EXPIRED:case exports.SendbirdErrorCode.SESSION_TOKEN_EXPIRED:case exports.SendbirdErrorCode.SESSION_REVOKED:this.error=new o({code:t})}}get invalidateSessionToken(){var e;return!!(null===(e=this.error)||void 0===e?void 0:e.isSessionTokenExpiredError)}}class de extends A{constructor(e){super(),this.statLog=e}}exports.StatType=void 0,(ne=exports.StatType||(exports.StatType={})).FEATURE_LOCALCACHE="feature:local_cache",ne.WEBSOCKET_CONNECT="ws:connect",ne.API_RESULT="api:result";class ce{constructor({type:e,data:t,ts:s=Date.now()}){this.type=e,this.createdAt=s,this.data=t}static payloadify(e){return N({stat_type:e.type,ts:e.createdAt,data:N(e.data)})}}const he=()=>"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product;class ue{constructor(e,{auth:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:o=!1}){this._abortControl=new Map,this._shouldImportFetchCompat=!1,this._iid=e,this._auth=t,this._sdkState=s,this._dispatcher=i,this._dispatcher.on((e=>{e instanceof ae&&this.cancel(e.requestId)})),this._logger=n,this._shouldImportFetchCompat=o}get _userAgentWithExtension(){const{extensions:e}=this._sdkState,t=he()?"reactnative":"JS";let s="//";if(e){s=`${e.sb_syncmanager?`s${e.sb_syncmanager}`:""}/${e.sb_uikit?`u${e.sb_uikit}`:""}/${e["device-os-platform"]?`o${e["device-os-platform"]}`:""}`}return`${t}/c${i.SDK_VERSION}/${s}`}_createHeader(e,t){const{appId:s,appVersion:n}=this._sdkState,o=Object.assign(Object.assign({},e.headers),{SendBird:`JS,${i.OS_VERSION},${i.SDK_VERSION},${s}${n?`,${n}`:""}`,"SB-User-Agent":encodeURIComponent(this._userAgentWithExtension),"Request-Sent-Timestamp":Date.now().toString()});return t||(o["Content-Type"]="application/json; charset=utf-8"),e.requireAuth&&this._auth.hasSession&&(o["Session-Key"]=this._auth.sessionKey),this._auth&&this._auth.authToken&&(o["App-Id"]=s,o["Access-Token"]=this._auth.authToken),o}_statLogApiResult(e,t,s){this._dispatcher.dispatch(new de(new ce({type:exports.StatType.API_RESULT,data:{endpoint:e.path,method:e.method,success:!s,latency:Date.now()-t,error_code:null==s?void 0:s.code,error_description:null==s?void 0:s.message}})))}send(t){return e(this,void 0,void 0,(function*(){const{path:e,method:s}=t,i=![exports.APIRequestMethod.GET,exports.APIRequestMethod.DELETE].includes(s),{api:n}=this._sdkState,r=`${n.host}${e}${i?"":t.query}`,a=i?t.payload:null,l=this._createHeader(t,a instanceof FormData?a:void 0),d=new AbortController,{signal:c}=d;this._abortControl.set(t.requestId,d);const h=Date.now();try{if(this._shouldImportFetchCompat){this._shouldImportFetchCompat=!1;("undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{fetch:null}).fetch=null}"undefined"==typeof AbortController&&(yield Promise.resolve().then((function(){return require("./__bundle-72519a03.js")}))),"function"!=typeof fetch&&(yield Promise.resolve().then((function(){return require("./__bundle-491c6c05.js")})));const e=yield fetch(r,{method:s,body:a,headers:l,signal:c}),i=yield e.json();if(e.ok||e.redirected)return this._logger.debug("receive api response",t.requestId),this._statLogApiResult(t,h),new re(this._iid,i);if(i){const e=new o(i);throw(e.isSessionKeyExpiredError||e.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new le({reason:e.code})),this._statLogApiResult(t,h,e),e}{const e=o.requestFailed;throw this._statLogApiResult(t,h,e),e}}catch(e){if(this._statLogApiResult(t,h,e),e instanceof o)throw this._logger.debug("fail api request",e),e;if("AbortError"===e.name)throw o.requestCanceled;{const e=o.networkError;throw this._logger.debug("fail api request",e),e}}}))}cancel(e){if(this._abortControl.has(e)){this._abortControl.get(e).abort(),this._abortControl.delete(e)}}cancelAll(){for(const e of this._abortControl.values())e.abort();this._abortControl.clear()}}class _e extends A{constructor(e,t,s,i=""){var n;super(),this._iid=e,this.code=t,this.payload=s,this.requestId=null!==(n=s.req_id)&&void 0!==n?n:i}static createFromRawMessage(e,t){let s=t.substring(0,4),i={};try{i=JSON.parse(t.substring(4))}catch(e){s="NOOP"}finally{return new _e(e,s,i)}}convertToMessage(){return`${this.code}${JSON.stringify(this.payload)}\n`}as(e){return new e(this._iid,this.code,this.payload)}}const pe=()=>{}; +/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */function ge(e){let t=e.length;for(;--t>=0;)e[t]=0}const fe=256,Ee=286,ve=30,me=15,Se=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]),ye=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]),be=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ce=new Array(576);ge(Ce);const Te=new Array(60);ge(Te);const ke=new Array(512);ge(ke);const xe=new Array(256);ge(xe);const Ae=new Array(29);ge(Ae);const Ne=new Array(ve);function Ie(e,t,s,i,n){this.static_tree=e,this.extra_bits=t,this.extra_base=s,this.elems=i,this.max_length=n,this.has_stree=e&&e.length}let Re,Oe,De;function Le(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}ge(Ne);const Me=e=>e<256?ke[e]:ke[256+(e>>>7)],Ue=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},Pe=(e,t,s)=>{e.bi_valid>16-s?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=s-16):(e.bi_buf|=t<{Pe(e,s[2*t],s[2*t+1])},Fe=(e,t)=>{let s=0;do{s|=1&e,e>>>=1,s<<=1}while(--t>0);return s>>>1},qe=(e,t,s)=>{const i=new Array(16);let n,o,r=0;for(n=1;n<=me;n++)r=r+s[n-1]<<1,i[n]=r;for(o=0;o<=t;o++){let t=e[2*o+1];0!==t&&(e[2*o]=Fe(i[t]++,t))}},Ge=e=>{let t;for(t=0;t{e.bi_valid>8?Ue(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Be=(e,t,s,i)=>{const n=2*t,o=2*s;return e[n]{const i=e.heap[s];let n=s<<1;for(;n<=e.heap_len&&(n{let i,n,o,r,a=0;if(0!==e.sym_next)do{i=255&e.pending_buf[e.sym_buf+a++],i+=(255&e.pending_buf[e.sym_buf+a++])<<8,n=e.pending_buf[e.sym_buf+a++],0===i?ze(e,n,t):(o=xe[n],ze(e,o+fe+1,t),r=Se[o],0!==r&&(n-=Ae[o],Pe(e,n,r)),i--,o=Me(i),ze(e,o,s),r=ye[o],0!==r&&(i-=Ne[o],Pe(e,i,r)))}while(a{const s=t.dyn_tree,i=t.stat_desc.static_tree,n=t.stat_desc.has_stree,o=t.stat_desc.elems;let r,a,l,d=-1;for(e.heap_len=0,e.heap_max=573,r=0;r>1;r>=1;r--)He(e,s,r);l=o;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],He(e,s,1),a=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=a,s[2*l]=s[2*r]+s[2*a],e.depth[l]=(e.depth[r]>=e.depth[a]?e.depth[r]:e.depth[a])+1,s[2*r+1]=s[2*a+1]=l,e.heap[1]=l++,He(e,s,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const s=t.dyn_tree,i=t.max_code,n=t.stat_desc.static_tree,o=t.stat_desc.has_stree,r=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,l=t.stat_desc.max_length;let d,c,h,u,_,p,g=0;for(u=0;u<=me;u++)e.bl_count[u]=0;for(s[2*e.heap[e.heap_max]+1]=0,d=e.heap_max+1;d<573;d++)c=e.heap[d],u=s[2*s[2*c+1]+1]+1,u>l&&(u=l,g++),s[2*c+1]=u,c>i||(e.bl_count[u]++,_=0,c>=a&&(_=r[c-a]),p=s[2*c],e.opt_len+=p*(u+_),o&&(e.static_len+=p*(n[2*c+1]+_)));if(0!==g){do{for(u=l-1;0===e.bl_count[u];)u--;e.bl_count[u]--,e.bl_count[u+1]+=2,e.bl_count[l]--,g-=2}while(g>0);for(u=l;0!==u;u--)for(c=e.bl_count[u];0!==c;)h=e.heap[--d],h>i||(s[2*h+1]!==u&&(e.opt_len+=(u-s[2*h+1])*s[2*h],s[2*h+1]=u),c--)}})(e,t),qe(s,d,e.bl_count)},$e=(e,t,s)=>{let i,n,o=-1,r=t[1],a=0,l=7,d=4;for(0===r&&(l=138,d=3),t[2*(s+1)+1]=65535,i=0;i<=s;i++)n=r,r=t[2*(i+1)+1],++a{let i,n,o=-1,r=t[1],a=0,l=7,d=4;for(0===r&&(l=138,d=3),i=0;i<=s;i++)if(n=r,r=t[2*(i+1)+1],!(++a{Pe(e,0+(i?1:0),3),Ke(e),Ue(e,s),Ue(e,~s),s&&e.pending_buf.set(e.window.subarray(t,t+s),e.pending),e.pending+=s};var Ye=(e,t,s,i)=>{let n,o,r=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,s=4093624447;for(t=0;t<=31;t++,s>>>=1)if(1&s&&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($e(e,e.dyn_ltree,e.l_desc.max_code),$e(e,e.dyn_dtree,e.d_desc.max_code),je(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*be[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),n=e.opt_len+3+7>>>3,o=e.static_len+3+7>>>3,o<=n&&(n=o)):n=o=s+5,s+4<=n&&-1!==t?Qe(e,t,s,i):4===e.strategy||o===n?(Pe(e,2+(i?1:0),3),Ve(e,Ce,Te)):(Pe(e,4+(i?1:0),3),((e,t,s,i)=>{let n;for(Pe(e,t-257,5),Pe(e,s-1,5),Pe(e,i-4,4),n=0;n{We||((()=>{let e,t,s,i,n;const o=new Array(16);for(s=0,i=0;i<28;i++)for(Ae[i]=s,e=0;e<1<>=7;i(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++]=s,0===t?e.dyn_ltree[2*s]++:(e.matches++,t--,e.dyn_ltree[2*(xe[s]+fe+1)]++,e.dyn_dtree[2*Me(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{Pe(e,2,3),ze(e,256,Ce),(e=>{16===e.bi_valid?(Ue(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 Je=(e,t,s,i)=>{let n=65535&e|0,o=e>>>16&65535|0,r=0;for(;0!==s;){r=s>2e3?2e3:s,s-=r;do{n=n+t[i++]|0,o=o+n|0}while(--r);n%=65521,o%=65521}return n|o<<16|0};const et=new Uint32Array((()=>{let e,t=[];for(var s=0;s<256;s++){e=s;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[s]=e}return t})());var tt=(e,t,s,i)=>{const n=et,o=i+s;e^=-1;for(let s=i;s>>8^n[255&(e^t[s])];return-1^e},st={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"},it={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:nt,_tr_stored_block:ot,_tr_flush_block:rt,_tr_tally:at,_tr_align:lt}=Xe,{Z_NO_FLUSH:dt,Z_PARTIAL_FLUSH:ct,Z_FULL_FLUSH:ht,Z_FINISH:ut,Z_BLOCK:_t,Z_OK:pt,Z_STREAM_END:gt,Z_STREAM_ERROR:ft,Z_DATA_ERROR:Et,Z_BUF_ERROR:vt,Z_DEFAULT_COMPRESSION:mt,Z_FILTERED:St,Z_HUFFMAN_ONLY:yt,Z_RLE:wt,Z_FIXED:bt,Z_DEFAULT_STRATEGY:Ct,Z_UNKNOWN:Tt,Z_DEFLATED:kt}=it,xt=258,At=262,Nt=42,It=113,Rt=666,Ot=(e,t)=>(e.msg=st[t],t),Dt=e=>2*e-(e>4?9:0),Lt=e=>{let t=e.length;for(;--t>=0;)e[t]=0},Mt=e=>{let t,s,i,n=e.w_size;t=e.hash_size,i=t;do{s=e.head[--i],e.head[i]=s>=n?s-n:0}while(--t);t=n,i=t;do{s=e.prev[--i],e.prev[i]=s>=n?s-n:0}while(--t)};let Ut=(e,t,s)=>(t<{const t=e.state;let s=t.pending;s>e.avail_out&&(s=e.avail_out),0!==s&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+s),e.next_out),e.next_out+=s,t.pending_out+=s,e.total_out+=s,e.avail_out-=s,t.pending-=s,0===t.pending&&(t.pending_out=0))},zt=(e,t)=>{rt(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Pt(e.strm)},Ft=(e,t)=>{e.pending_buf[e.pending++]=t},qt=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},Gt=(e,t,s,i)=>{let n=e.avail_in;return n>i&&(n=i),0===n?0:(e.avail_in-=n,t.set(e.input.subarray(e.next_in,e.next_in+n),s),1===e.state.wrap?e.adler=Je(e.adler,t,n,s):2===e.state.wrap&&(e.adler=tt(e.adler,t,n,s)),e.next_in+=n,e.total_in+=n,n)},Kt=(e,t)=>{let s,i,n=e.max_chain_length,o=e.strstart,r=e.prev_length,a=e.nice_match;const l=e.strstart>e.w_size-At?e.strstart-(e.w_size-At):0,d=e.window,c=e.w_mask,h=e.prev,u=e.strstart+xt;let _=d[o+r-1],p=d[o+r];e.prev_length>=e.good_match&&(n>>=2),a>e.lookahead&&(a=e.lookahead);do{if(s=t,d[s+r]===p&&d[s+r-1]===_&&d[s]===d[o]&&d[++s]===d[o+1]){o+=2,s++;do{}while(d[++o]===d[++s]&&d[++o]===d[++s]&&d[++o]===d[++s]&&d[++o]===d[++s]&&d[++o]===d[++s]&&d[++o]===d[++s]&&d[++o]===d[++s]&&d[++o]===d[++s]&&or){if(e.match_start=t,r=i,i>=a)break;_=d[o+r-1],p=d[o+r]}}}while((t=h[t&c])>l&&0!=--n);return r<=e.lookahead?r:e.lookahead},Bt=e=>{const t=e.w_size;let s,i,n;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-At)&&(e.window.set(e.window.subarray(t,t+t-i),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),Mt(e),i+=t),0===e.strm.avail_in)break;if(s=Gt(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=s,e.lookahead+e.insert>=3)for(n=e.strstart-e.insert,e.ins_h=e.window[n],e.ins_h=Ut(e,e.ins_h,e.window[n+1]);e.insert&&(e.ins_h=Ut(e,e.ins_h,e.window[n+3-1]),e.prev[n&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=n,n++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead{let s,i,n,o=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,r=0,a=e.strm.avail_in;do{if(s=65535,n=e.bi_valid+42>>3,e.strm.avail_outi+e.strm.avail_in&&(s=i+e.strm.avail_in),s>n&&(s=n),s>8,e.pending_buf[e.pending-2]=~s,e.pending_buf[e.pending-1]=~s>>8,Pt(e.strm),i&&(i>s&&(i=s),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+i),e.strm.next_out),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i,e.block_start+=i,s-=i),s&&(Gt(e.strm,e.strm.output,e.strm.next_out,s),e.strm.next_out+=s,e.strm.avail_out-=s,e.strm.total_out+=s)}while(0===r);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_watern&&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++,n+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),n>e.strm.avail_in&&(n=e.strm.avail_in),n&&(Gt(e.strm,e.window,e.strstart,n),e.strstart+=n,e.insert+=n>e.w_size-e.insert?e.w_size-e.insert:n),e.high_water>3,n=e.pending_buf_size-n>65535?65535:e.pending_buf_size-n,o=n>e.w_size?e.w_size:n,i=e.strstart-e.block_start,(i>=o||(i||t===ut)&&t!==dt&&0===e.strm.avail_in&&i<=n)&&(s=i>n?n:i,r=t===ut&&0===e.strm.avail_in&&s===i?1:0,ot(e,e.block_start,s,r),e.block_start+=s,Pt(e.strm)),r?3:1)},Vt=(e,t)=>{let s,i;for(;;){if(e.lookahead=3&&(e.ins_h=Ut(e,e.ins_h,e.window[e.strstart+3-1]),s=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==s&&e.strstart-s<=e.w_size-At&&(e.match_length=Kt(e,s)),e.match_length>=3)if(i=at(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=Ut(e,e.ins_h,e.window[e.strstart+3-1]),s=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=Ut(e,e.ins_h,e.window[e.strstart+1]);else i=at(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(zt(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===ut?(zt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(zt(e,!1),0===e.strm.avail_out)?1:2},jt=(e,t)=>{let s,i,n;for(;;){if(e.lookahead=3&&(e.ins_h=Ut(e,e.ins_h,e.window[e.strstart+3-1]),s=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!==s&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){n=e.strstart+e.lookahead-3,i=at(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=n&&(e.ins_h=Ut(e,e.ins_h,e.window[e.strstart+3-1]),s=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++,i&&(zt(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(i=at(e,0,e.window[e.strstart-1]),i&&zt(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&&(i=at(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===ut?(zt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(zt(e,!1),0===e.strm.avail_out)?1:2};function $t(e,t,s,i,n){this.good_length=e,this.max_lazy=t,this.nice_length=s,this.max_chain=i,this.func=n}const Zt=[new $t(0,0,0,0,Ht),new $t(4,4,8,4,Vt),new $t(4,5,16,8,Vt),new $t(4,6,32,32,Vt),new $t(4,4,16,16,jt),new $t(8,16,32,32,jt),new $t(8,16,128,128,jt),new $t(8,32,128,256,jt),new $t(32,128,258,1024,jt),new $t(32,258,258,4096,jt)];function Wt(){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=kt,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),Lt(this.dyn_ltree),Lt(this.dyn_dtree),Lt(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),Lt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Lt(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 Qt=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==Nt&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==It&&t.status!==Rt?1:0},Yt=e=>{if(Qt(e))return Ot(e,ft);e.total_in=e.total_out=0,e.data_type=Tt;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?Nt:It,e.adler=2===t.wrap?0:1,t.last_flush=-2,nt(t),pt},Xt=e=>{const t=Yt(e);var s;return t===pt&&((s=e.state).window_size=2*s.w_size,Lt(s.head),s.max_lazy_match=Zt[s.level].max_lazy,s.good_match=Zt[s.level].good_length,s.nice_match=Zt[s.level].nice_length,s.max_chain_length=Zt[s.level].max_chain,s.strstart=0,s.block_start=0,s.lookahead=0,s.insert=0,s.match_length=s.prev_length=2,s.match_available=0,s.ins_h=0),t},Jt=(e,t,s,i,n,o)=>{if(!e)return ft;let r=1;if(t===mt&&(t=6),i<0?(r=0,i=-i):i>15&&(r=2,i-=16),n<1||n>9||s!==kt||i<8||i>15||t<0||t>9||o<0||o>bt||8===i&&1!==r)return Ot(e,ft);8===i&&(i=9);const a=new Wt;return e.state=a,a.strm=e,a.status=Nt,a.wrap=r,a.gzhead=null,a.w_bits=i,a.w_size=1<Jt(e,t,kt,15,8,Ct),deflateInit2:Jt,deflateReset:Xt,deflateResetKeep:Yt,deflateSetHeader:(e,t)=>Qt(e)||2!==e.state.wrap?ft:(e.state.gzhead=t,pt),deflate:(e,t)=>{if(Qt(e)||t>_t||t<0)return e?Ot(e,ft):ft;const s=e.state;if(!e.output||0!==e.avail_in&&!e.input||s.status===Rt&&t!==ut)return Ot(e,0===e.avail_out?vt:ft);const i=s.last_flush;if(s.last_flush=t,0!==s.pending){if(Pt(e),0===e.avail_out)return s.last_flush=-1,pt}else if(0===e.avail_in&&Dt(t)<=Dt(i)&&t!==ut)return Ot(e,vt);if(s.status===Rt&&0!==e.avail_in)return Ot(e,vt);if(s.status===Nt&&0===s.wrap&&(s.status=It),s.status===Nt){let t=kt+(s.w_bits-8<<4)<<8,i=-1;if(i=s.strategy>=yt||s.level<2?0:s.level<6?1:6===s.level?2:3,t|=i<<6,0!==s.strstart&&(t|=32),t+=31-t%31,qt(s,t),0!==s.strstart&&(qt(s,e.adler>>>16),qt(s,65535&e.adler)),e.adler=1,s.status=It,Pt(e),0!==s.pending)return s.last_flush=-1,pt}if(57===s.status)if(e.adler=0,Ft(s,31),Ft(s,139),Ft(s,8),s.gzhead)Ft(s,(s.gzhead.text?1:0)+(s.gzhead.hcrc?2:0)+(s.gzhead.extra?4:0)+(s.gzhead.name?8:0)+(s.gzhead.comment?16:0)),Ft(s,255&s.gzhead.time),Ft(s,s.gzhead.time>>8&255),Ft(s,s.gzhead.time>>16&255),Ft(s,s.gzhead.time>>24&255),Ft(s,9===s.level?2:s.strategy>=yt||s.level<2?4:0),Ft(s,255&s.gzhead.os),s.gzhead.extra&&s.gzhead.extra.length&&(Ft(s,255&s.gzhead.extra.length),Ft(s,s.gzhead.extra.length>>8&255)),s.gzhead.hcrc&&(e.adler=tt(e.adler,s.pending_buf,s.pending,0)),s.gzindex=0,s.status=69;else if(Ft(s,0),Ft(s,0),Ft(s,0),Ft(s,0),Ft(s,0),Ft(s,9===s.level?2:s.strategy>=yt||s.level<2?4:0),Ft(s,3),s.status=It,Pt(e),0!==s.pending)return s.last_flush=-1,pt;if(69===s.status){if(s.gzhead.extra){let t=s.pending,i=(65535&s.gzhead.extra.length)-s.gzindex;for(;s.pending+i>s.pending_buf_size;){let n=s.pending_buf_size-s.pending;if(s.pending_buf.set(s.gzhead.extra.subarray(s.gzindex,s.gzindex+n),s.pending),s.pending=s.pending_buf_size,s.gzhead.hcrc&&s.pending>t&&(e.adler=tt(e.adler,s.pending_buf,s.pending-t,t)),s.gzindex+=n,Pt(e),0!==s.pending)return s.last_flush=-1,pt;t=0,i-=n}let n=new Uint8Array(s.gzhead.extra);s.pending_buf.set(n.subarray(s.gzindex,s.gzindex+i),s.pending),s.pending+=i,s.gzhead.hcrc&&s.pending>t&&(e.adler=tt(e.adler,s.pending_buf,s.pending-t,t)),s.gzindex=0}s.status=73}if(73===s.status){if(s.gzhead.name){let t,i=s.pending;do{if(s.pending===s.pending_buf_size){if(s.gzhead.hcrc&&s.pending>i&&(e.adler=tt(e.adler,s.pending_buf,s.pending-i,i)),Pt(e),0!==s.pending)return s.last_flush=-1,pt;i=0}t=s.gzindexi&&(e.adler=tt(e.adler,s.pending_buf,s.pending-i,i)),s.gzindex=0}s.status=91}if(91===s.status){if(s.gzhead.comment){let t,i=s.pending;do{if(s.pending===s.pending_buf_size){if(s.gzhead.hcrc&&s.pending>i&&(e.adler=tt(e.adler,s.pending_buf,s.pending-i,i)),Pt(e),0!==s.pending)return s.last_flush=-1,pt;i=0}t=s.gzindexi&&(e.adler=tt(e.adler,s.pending_buf,s.pending-i,i))}s.status=103}if(103===s.status){if(s.gzhead.hcrc){if(s.pending+2>s.pending_buf_size&&(Pt(e),0!==s.pending))return s.last_flush=-1,pt;Ft(s,255&e.adler),Ft(s,e.adler>>8&255),e.adler=0}if(s.status=It,Pt(e),0!==s.pending)return s.last_flush=-1,pt}if(0!==e.avail_in||0!==s.lookahead||t!==dt&&s.status!==Rt){let i=0===s.level?Ht(s,t):s.strategy===yt?((e,t)=>{let s;for(;;){if(0===e.lookahead&&(Bt(e),0===e.lookahead)){if(t===dt)return 1;break}if(e.match_length=0,s=at(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,s&&(zt(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===ut?(zt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(zt(e,!1),0===e.strm.avail_out)?1:2})(s,t):s.strategy===wt?((e,t)=>{let s,i,n,o;const r=e.window;for(;;){if(e.lookahead<=xt){if(Bt(e),e.lookahead<=xt&&t===dt)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=e.strstart-1,i=r[n],i===r[++n]&&i===r[++n]&&i===r[++n])){o=e.strstart+xt;do{}while(i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&ne.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(s=at(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(s=at(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),s&&(zt(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===ut?(zt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(zt(e,!1),0===e.strm.avail_out)?1:2})(s,t):Zt[s.level].func(s,t);if(3!==i&&4!==i||(s.status=Rt),1===i||3===i)return 0===e.avail_out&&(s.last_flush=-1),pt;if(2===i&&(t===ct?lt(s):t!==_t&&(ot(s,0,0,!1),t===ht&&(Lt(s.head),0===s.lookahead&&(s.strstart=0,s.block_start=0,s.insert=0))),Pt(e),0===e.avail_out))return s.last_flush=-1,pt}return t!==ut?pt:s.wrap<=0?gt:(2===s.wrap?(Ft(s,255&e.adler),Ft(s,e.adler>>8&255),Ft(s,e.adler>>16&255),Ft(s,e.adler>>24&255),Ft(s,255&e.total_in),Ft(s,e.total_in>>8&255),Ft(s,e.total_in>>16&255),Ft(s,e.total_in>>24&255)):(qt(s,e.adler>>>16),qt(s,65535&e.adler)),Pt(e),s.wrap>0&&(s.wrap=-s.wrap),0!==s.pending?pt:gt)},deflateEnd:e=>{if(Qt(e))return ft;const t=e.state.status;return e.state=null,t===It?Ot(e,Et):pt},deflateSetDictionary:(e,t)=>{let s=t.length;if(Qt(e))return ft;const i=e.state,n=i.wrap;if(2===n||1===n&&i.status!==Nt||i.lookahead)return ft;if(1===n&&(e.adler=Je(e.adler,t,s,0)),i.wrap=0,s>=i.w_size){0===n&&(Lt(i.head),i.strstart=0,i.block_start=0,i.insert=0);let e=new Uint8Array(i.w_size);e.set(t.subarray(s-i.w_size,s),0),t=e,s=i.w_size}const o=e.avail_in,r=e.next_in,a=e.input;for(e.avail_in=s,e.next_in=0,e.input=t,Bt(i);i.lookahead>=3;){let e=i.strstart,t=i.lookahead-2;do{i.ins_h=Ut(i,i.ins_h,i.window[e+3-1]),i.prev[e&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=e,e++}while(--t);i.strstart=e,i.lookahead=2,Bt(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=2,i.match_available=0,e.next_in=r,e.input=a,e.avail_in=o,i.wrap=n,pt},deflateInfo:"pako deflate (from Nodeca project)"};const ts=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var ss={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const s=t.shift();if(s){if("object"!=typeof s)throw new TypeError(s+"must be non-object");for(const t in s)ts(s,t)&&(e[t]=s[t])}}return e},flattenChunks:e=>{let t=0;for(let s=0,i=e.length;s=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;ns[254]=ns[254]=1;var os={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,s,i,n,o,r=e.length,a=0;for(n=0;n>>6,t[o++]=128|63&s):s<65536?(t[o++]=224|s>>>12,t[o++]=128|s>>>6&63,t[o++]=128|63&s):(t[o++]=240|s>>>18,t[o++]=128|s>>>12&63,t[o++]=128|s>>>6&63,t[o++]=128|63&s);return t},buf2string:(e,t)=>{const s=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let i,n;const o=new Array(2*s);for(n=0,i=0;i4)o[n++]=65533,i+=r-1;else{for(t&=2===r?31:3===r?15:7;r>1&&i1?o[n++]=65533:t<65536?o[n++]=t:(t-=65536,o[n++]=55296|t>>10&1023,o[n++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&is)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let s="";for(let i=0;i{(t=t||e.length)>e.length&&(t=e.length);let s=t-1;for(;s>=0&&128==(192&e[s]);)s--;return s<0||0===s?t:s+ns[e[s]]>t?s:t}};var rs=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 as=Object.prototype.toString,{Z_NO_FLUSH:ls,Z_SYNC_FLUSH:ds,Z_FULL_FLUSH:cs,Z_FINISH:hs,Z_OK:us,Z_STREAM_END:_s,Z_DEFAULT_COMPRESSION:ps,Z_DEFAULT_STRATEGY:gs,Z_DEFLATED:fs}=it;function Es(e){this.options=ss.assign({level:ps,method:fs,chunkSize:16384,windowBits:15,memLevel:8,strategy:gs},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 rs,this.strm.avail_out=0;let s=es.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(s!==us)throw new Error(st[s]);if(t.header&&es.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?os.string2buf(t.dictionary):"[object ArrayBuffer]"===as.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,s=es.deflateSetDictionary(this.strm,e),s!==us)throw new Error(st[s]);this._dict_set=!0}}function vs(e,t){const s=new Es(t);if(s.push(e,!0),s.err)throw s.msg||st[s.err];return s.result}Es.prototype.push=function(e,t){const s=this.strm,i=this.options.chunkSize;let n,o;if(this.ended)return!1;for(o=t===~~t?t:!0===t?hs:ls,"string"==typeof e?s.input=os.string2buf(e):"[object ArrayBuffer]"===as.call(e)?s.input=new Uint8Array(e):s.input=e,s.next_in=0,s.avail_in=s.input.length;;)if(0===s.avail_out&&(s.output=new Uint8Array(i),s.next_out=0,s.avail_out=i),(o===ds||o===cs)&&s.avail_out<=6)this.onData(s.output.subarray(0,s.next_out)),s.avail_out=0;else{if(n=es.deflate(s,o),n===_s)return s.next_out>0&&this.onData(s.output.subarray(0,s.next_out)),n=es.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===us;if(0!==s.avail_out){if(o>0&&s.next_out>0)this.onData(s.output.subarray(0,s.next_out)),s.avail_out=0;else if(0===s.avail_in)break}else this.onData(s.output)}return!0},Es.prototype.onData=function(e){this.chunks.push(e)},Es.prototype.onEnd=function(e){e===us&&(this.result=ss.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var ms={Deflate:Es,deflate:vs,deflateRaw:function(e,t){return(t=t||{}).raw=!0,vs(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,vs(e,t)},constants:it};const Ss=16209;var ys=function(e,t){let s,i,n,o,r,a,l,d,c,h,u,_,p,g,f,E,v,m,S,y,w,b,C,T;const k=e.state;s=e.next_in,C=e.input,i=s+(e.avail_in-5),n=e.next_out,T=e.output,o=n-(t-e.avail_out),r=n+(e.avail_out-257),a=k.dmax,l=k.wsize,d=k.whave,c=k.wnext,h=k.window,u=k.hold,_=k.bits,p=k.lencode,g=k.distcode,f=(1<>>24,u>>>=m,_-=m,m=v>>>16&255,0===m)T[n++]=65535&v;else{if(!(16&m)){if(0==(64&m)){v=p[(65535&v)+(u&(1<>>=m,_-=m),_<15&&(u+=C[s++]<<_,_+=8,u+=C[s++]<<_,_+=8),v=g[u&E];s:for(;;){if(m=v>>>24,u>>>=m,_-=m,m=v>>>16&255,!(16&m)){if(0==(64&m)){v=g[(65535&v)+(u&(1<a){e.msg="invalid distance too far back",k.mode=Ss;break e}if(u>>>=m,_-=m,m=n-o,y>m){if(m=y-m,m>d&&k.sane){e.msg="invalid distance too far back",k.mode=Ss;break e}if(w=0,b=h,0===c){if(w+=l-m,m2;)T[n++]=b[w++],T[n++]=b[w++],T[n++]=b[w++],S-=3;S&&(T[n++]=b[w++],S>1&&(T[n++]=b[w++]))}else{w=n-y;do{T[n++]=T[w++],T[n++]=T[w++],T[n++]=T[w++],S-=3}while(S>2);S&&(T[n++]=T[w++],S>1&&(T[n++]=T[w++]))}break}}break}}while(s>3,s-=S,_-=S<<3,u&=(1<<_)-1,e.next_in=s,e.next_out=n,e.avail_in=s{const l=a.bits;let d,c,h,u,_,p,g=0,f=0,E=0,v=0,m=0,S=0,y=0,w=0,b=0,C=0,T=null;const k=new Uint16Array(16),x=new Uint16Array(16);let A,N,I,R=null;for(g=0;g<=ws;g++)k[g]=0;for(f=0;f=1&&0===k[v];v--);if(m>v&&(m=v),0===v)return n[o++]=20971520,n[o++]=20971520,a.bits=1,0;for(E=1;E0&&(0===e||1!==v))return-1;for(x[1]=0,g=1;g852||2===e&&b>592)return 1;for(;;){A=g-y,r[f]+1=p?(N=R[r[f]-p],I=T[r[f]-p]):(N=96,I=0),d=1<>y)+c]=A<<24|N<<16|I|0}while(0!==c);for(d=1<>=1;if(0!==d?(C&=d-1,C+=d):C=0,f++,0==--k[g]){if(g===v)break;g=t[s+r[f]]}if(g>m&&(C&u)!==h){for(0===y&&(y=m),_+=E,S=g-y,w=1<852||2===e&&b>592)return 1;h=C&u,n[h]=m<<24|S<<16|_-o|0}}return 0!==C&&(n[_+C]=g-y<<24|64<<16|0),a.bits=m,0};const{Z_FINISH:As,Z_BLOCK:Ns,Z_TREES:Is,Z_OK:Rs,Z_STREAM_END:Os,Z_NEED_DICT:Ds,Z_STREAM_ERROR:Ls,Z_DATA_ERROR:Ms,Z_MEM_ERROR:Us,Z_BUF_ERROR:Ps,Z_DEFLATED:zs}=it,Fs=16180,qs=16190,Gs=16191,Ks=16192,Bs=16194,Hs=16199,Vs=16200,js=16206,$s=16209,Zs=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Ws(){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 Qs=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},Ys=e=>{if(Qs(e))return Ls;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=Fs,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,Rs},Xs=e=>{if(Qs(e))return Ls;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Ys(e)},Js=(e,t)=>{let s;if(Qs(e))return Ls;const i=e.state;return t<0?(s=0,t=-t):(s=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Ls:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=s,i.wbits=t,Xs(e))},ei=(e,t)=>{if(!e)return Ls;const s=new Ws;e.state=s,s.strm=e,s.window=null,s.mode=Fs;const i=Js(e,t);return i!==Rs&&(e.state=null),i};let ti,si,ii=!0;const ni=e=>{if(ii){ti=new Int32Array(512),si=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(xs(1,e.lens,0,288,ti,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;xs(2,e.lens,0,32,si,0,e.work,{bits:5}),ii=!1}e.lencode=ti,e.lenbits=9,e.distcode=si,e.distbits=5},oi=(e,t,s,i)=>{let n;const o=e.state;return null===o.window&&(o.wsize=1<=o.wsize?(o.window.set(t.subarray(s-o.wsize,s),0),o.wnext=0,o.whave=o.wsize):(n=o.wsize-o.wnext,n>i&&(n=i),o.window.set(t.subarray(s-i,s-i+n),o.wnext),(i-=n)?(o.window.set(t.subarray(s-i,s),0),o.wnext=i,o.whave=o.wsize):(o.wnext+=n,o.wnext===o.wsize&&(o.wnext=0),o.whaveei(e,15),inflateInit2:ei,inflate:(e,t)=>{let s,i,n,o,r,a,l,d,c,h,u,_,p,g,f,E,v,m,S,y,w,b,C=0;const T=new Uint8Array(4);let k,x;const A=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Qs(e)||!e.output||!e.input&&0!==e.avail_in)return Ls;s=e.state,s.mode===Gs&&(s.mode=Ks),r=e.next_out,n=e.output,l=e.avail_out,o=e.next_in,i=e.input,a=e.avail_in,d=s.hold,c=s.bits,h=a,u=l,b=Rs;e:for(;;)switch(s.mode){case Fs:if(0===s.wrap){s.mode=Ks;break}for(;c<16;){if(0===a)break e;a--,d+=i[o++]<>>8&255,s.check=tt(s.check,T,2,0),d=0,c=0,s.mode=16181;break}if(s.head&&(s.head.done=!1),!(1&s.wrap)||(((255&d)<<8)+(d>>8))%31){e.msg="incorrect header check",s.mode=$s;break}if((15&d)!==zs){e.msg="unknown compression method",s.mode=$s;break}if(d>>>=4,c-=4,w=8+(15&d),0===s.wbits&&(s.wbits=w),w>15||w>s.wbits){e.msg="invalid window size",s.mode=$s;break}s.dmax=1<>8&1),512&s.flags&&4&s.wrap&&(T[0]=255&d,T[1]=d>>>8&255,s.check=tt(s.check,T,2,0)),d=0,c=0,s.mode=16182;case 16182:for(;c<32;){if(0===a)break e;a--,d+=i[o++]<>>8&255,T[2]=d>>>16&255,T[3]=d>>>24&255,s.check=tt(s.check,T,4,0)),d=0,c=0,s.mode=16183;case 16183:for(;c<16;){if(0===a)break e;a--,d+=i[o++]<>8),512&s.flags&&4&s.wrap&&(T[0]=255&d,T[1]=d>>>8&255,s.check=tt(s.check,T,2,0)),d=0,c=0,s.mode=16184;case 16184:if(1024&s.flags){for(;c<16;){if(0===a)break e;a--,d+=i[o++]<>>8&255,s.check=tt(s.check,T,2,0)),d=0,c=0}else s.head&&(s.head.extra=null);s.mode=16185;case 16185:if(1024&s.flags&&(_=s.length,_>a&&(_=a),_&&(s.head&&(w=s.head.extra_len-s.length,s.head.extra||(s.head.extra=new Uint8Array(s.head.extra_len)),s.head.extra.set(i.subarray(o,o+_),w)),512&s.flags&&4&s.wrap&&(s.check=tt(s.check,i,_,o)),a-=_,o+=_,s.length-=_),s.length))break e;s.length=0,s.mode=16186;case 16186:if(2048&s.flags){if(0===a)break e;_=0;do{w=i[o+_++],s.head&&w&&s.length<65536&&(s.head.name+=String.fromCharCode(w))}while(w&&_>9&1,s.head.done=!0),e.adler=s.check=0,s.mode=Gs;break;case 16189:for(;c<32;){if(0===a)break e;a--,d+=i[o++]<>>=7&c,c-=7&c,s.mode=js;break}for(;c<3;){if(0===a)break e;a--,d+=i[o++]<>>=1,c-=1,3&d){case 0:s.mode=16193;break;case 1:if(ni(s),s.mode=Hs,t===Is){d>>>=2,c-=2;break e}break;case 2:s.mode=16196;break;case 3:e.msg="invalid block type",s.mode=$s}d>>>=2,c-=2;break;case 16193:for(d>>>=7&c,c-=7&c;c<32;){if(0===a)break e;a--,d+=i[o++]<>>16^65535)){e.msg="invalid stored block lengths",s.mode=$s;break}if(s.length=65535&d,d=0,c=0,s.mode=Bs,t===Is)break e;case Bs:s.mode=16195;case 16195:if(_=s.length,_){if(_>a&&(_=a),_>l&&(_=l),0===_)break e;n.set(i.subarray(o,o+_),r),a-=_,o+=_,l-=_,r+=_,s.length-=_;break}s.mode=Gs;break;case 16196:for(;c<14;){if(0===a)break e;a--,d+=i[o++]<>>=5,c-=5,s.ndist=1+(31&d),d>>>=5,c-=5,s.ncode=4+(15&d),d>>>=4,c-=4,s.nlen>286||s.ndist>30){e.msg="too many length or distance symbols",s.mode=$s;break}s.have=0,s.mode=16197;case 16197:for(;s.have>>=3,c-=3}for(;s.have<19;)s.lens[A[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,k={bits:s.lenbits},b=xs(0,s.lens,0,19,s.lencode,0,s.work,k),s.lenbits=k.bits,b){e.msg="invalid code lengths set",s.mode=$s;break}s.have=0,s.mode=16198;case 16198:for(;s.have>>24,E=C>>>16&255,v=65535&C,!(f<=c);){if(0===a)break e;a--,d+=i[o++]<>>=f,c-=f,s.lens[s.have++]=v;else{if(16===v){for(x=f+2;c>>=f,c-=f,0===s.have){e.msg="invalid bit length repeat",s.mode=$s;break}w=s.lens[s.have-1],_=3+(3&d),d>>>=2,c-=2}else if(17===v){for(x=f+3;c>>=f,c-=f,w=0,_=3+(7&d),d>>>=3,c-=3}else{for(x=f+7;c>>=f,c-=f,w=0,_=11+(127&d),d>>>=7,c-=7}if(s.have+_>s.nlen+s.ndist){e.msg="invalid bit length repeat",s.mode=$s;break}for(;_--;)s.lens[s.have++]=w}}if(s.mode===$s)break;if(0===s.lens[256]){e.msg="invalid code -- missing end-of-block",s.mode=$s;break}if(s.lenbits=9,k={bits:s.lenbits},b=xs(1,s.lens,0,s.nlen,s.lencode,0,s.work,k),s.lenbits=k.bits,b){e.msg="invalid literal/lengths set",s.mode=$s;break}if(s.distbits=6,s.distcode=s.distdyn,k={bits:s.distbits},b=xs(2,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,k),s.distbits=k.bits,b){e.msg="invalid distances set",s.mode=$s;break}if(s.mode=Hs,t===Is)break e;case Hs:s.mode=Vs;case Vs:if(a>=6&&l>=258){e.next_out=r,e.avail_out=l,e.next_in=o,e.avail_in=a,s.hold=d,s.bits=c,ys(e,u),r=e.next_out,n=e.output,l=e.avail_out,o=e.next_in,i=e.input,a=e.avail_in,d=s.hold,c=s.bits,s.mode===Gs&&(s.back=-1);break}for(s.back=0;C=s.lencode[d&(1<>>24,E=C>>>16&255,v=65535&C,!(f<=c);){if(0===a)break e;a--,d+=i[o++]<>m)],f=C>>>24,E=C>>>16&255,v=65535&C,!(m+f<=c);){if(0===a)break e;a--,d+=i[o++]<>>=m,c-=m,s.back+=m}if(d>>>=f,c-=f,s.back+=f,s.length=v,0===E){s.mode=16205;break}if(32&E){s.back=-1,s.mode=Gs;break}if(64&E){e.msg="invalid literal/length code",s.mode=$s;break}s.extra=15&E,s.mode=16201;case 16201:if(s.extra){for(x=s.extra;c>>=s.extra,c-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=16202;case 16202:for(;C=s.distcode[d&(1<>>24,E=C>>>16&255,v=65535&C,!(f<=c);){if(0===a)break e;a--,d+=i[o++]<>m)],f=C>>>24,E=C>>>16&255,v=65535&C,!(m+f<=c);){if(0===a)break e;a--,d+=i[o++]<>>=m,c-=m,s.back+=m}if(d>>>=f,c-=f,s.back+=f,64&E){e.msg="invalid distance code",s.mode=$s;break}s.offset=v,s.extra=15&E,s.mode=16203;case 16203:if(s.extra){for(x=s.extra;c>>=s.extra,c-=s.extra,s.back+=s.extra}if(s.offset>s.dmax){e.msg="invalid distance too far back",s.mode=$s;break}s.mode=16204;case 16204:if(0===l)break e;if(_=u-l,s.offset>_){if(_=s.offset-_,_>s.whave&&s.sane){e.msg="invalid distance too far back",s.mode=$s;break}_>s.wnext?(_-=s.wnext,p=s.wsize-_):p=s.wnext-_,_>s.length&&(_=s.length),g=s.window}else g=n,p=r-s.offset,_=s.length;_>l&&(_=l),l-=_,s.length-=_;do{n[r++]=g[p++]}while(--_);0===s.length&&(s.mode=Vs);break;case 16205:if(0===l)break e;n[r++]=s.length,l--,s.mode=Vs;break;case js:if(s.wrap){for(;c<32;){if(0===a)break e;a--,d|=i[o++]<{if(Qs(e))return Ls;let t=e.state;return t.window&&(t.window=null),e.state=null,Rs},inflateGetHeader:(e,t)=>{if(Qs(e))return Ls;const s=e.state;return 0==(2&s.wrap)?Ls:(s.head=t,t.done=!1,Rs)},inflateSetDictionary:(e,t)=>{const s=t.length;let i,n,o;return Qs(e)?Ls:(i=e.state,0!==i.wrap&&i.mode!==qs?Ls:i.mode===qs&&(n=1,n=Je(n,t,s,0),n!==i.check)?Ms:(o=oi(e,t,s,s),o?(i.mode=16210,Us):(i.havedict=1,Rs)))},inflateInfo:"pako inflate (from Nodeca project)"};var ai=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 li=Object.prototype.toString,{Z_NO_FLUSH:di,Z_FINISH:ci,Z_OK:hi,Z_STREAM_END:ui,Z_NEED_DICT:_i,Z_STREAM_ERROR:pi,Z_DATA_ERROR:gi,Z_MEM_ERROR:fi}=it;function Ei(e){this.options=ss.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 rs,this.strm.avail_out=0;let s=ri.inflateInit2(this.strm,t.windowBits);if(s!==hi)throw new Error(st[s]);if(this.header=new ai,ri.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=os.string2buf(t.dictionary):"[object ArrayBuffer]"===li.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(s=ri.inflateSetDictionary(this.strm,t.dictionary),s!==hi)))throw new Error(st[s])}function vi(e,t){const s=new Ei(t);if(s.push(e),s.err)throw s.msg||st[s.err];return s.result}Ei.prototype.push=function(e,t){const s=this.strm,i=this.options.chunkSize,n=this.options.dictionary;let o,r,a;if(this.ended)return!1;for(r=t===~~t?t:!0===t?ci:di,"[object ArrayBuffer]"===li.call(e)?s.input=new Uint8Array(e):s.input=e,s.next_in=0,s.avail_in=s.input.length;;){for(0===s.avail_out&&(s.output=new Uint8Array(i),s.next_out=0,s.avail_out=i),o=ri.inflate(s,r),o===_i&&n&&(o=ri.inflateSetDictionary(s,n),o===hi?o=ri.inflate(s,r):o===gi&&(o=_i));s.avail_in>0&&o===ui&&s.state.wrap>0&&0!==e[s.next_in];)ri.inflateReset(s),o=ri.inflate(s,r);switch(o){case pi:case gi:case _i:case fi:return this.onEnd(o),this.ended=!0,!1}if(a=s.avail_out,s.next_out&&(0===s.avail_out||o===ui))if("string"===this.options.to){let e=os.utf8border(s.output,s.next_out),t=s.next_out-e,n=os.buf2string(s.output,e);s.next_out=t,s.avail_out=i-t,t&&s.output.set(s.output.subarray(e,e+t),0),this.onData(n)}else this.onData(s.output.length===s.next_out?s.output:s.output.subarray(0,s.next_out));if(o!==hi||0!==a){if(o===ui)return o=ri.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===s.avail_in)break}}return!0},Ei.prototype.onData=function(e){this.chunks.push(e)},Ei.prototype.onEnd=function(e){e===hi&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=ss.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var mi={Inflate:Ei,inflate:vi,inflateRaw:function(e,t){return(t=t||{}).raw=!0,vi(e,t)},ungzip:vi,constants:it};const{Deflate:Si,deflate:yi,deflateRaw:wi,gzip:bi}=ms,{Inflate:Ci,inflate:Ti,inflateRaw:ki,ungzip:xi}=mi;var Ai={Deflate:Si,deflate:yi,deflateRaw:wi,gzip:bi,Inflate:Ci,inflate:Ti,inflateRaw:ki,ungzip:xi,constants:it};var Ni,Ii;exports.ConnectionState=void 0,(Ni=exports.ConnectionState||(exports.ConnectionState={})).CONNECTING="CONNECTING",Ni.OPEN="OPEN",Ni.CLOSED="CLOSED";class Ri extends k{constructor(e,{sdkState:t,dispatcher:s,logger:i}){super(),this.lastActive=0,this._iid=e,this._sdkState=t,this._dispatcher=s,this._logger=i}get isOpen(){return this.connectionState===exports.ConnectionState.OPEN}get connectionState(){if(this._ws)switch(this._ws.readyState){case 0:return exports.ConnectionState.CONNECTING;case 1:return exports.ConnectionState.OPEN}return exports.ConnectionState.CLOSED}_handleMessage(e){e.split("\n").forEach((e=>{if(e){const t=_e.createFromRawMessage(this._iid,e);if(this._logger.debug("receive websocket event",t),"LOGI"===t.code)this.dispatch("message",t);else if("PONG"===t.code)this.dispatch("pong");else if("EXPR"===t.code){if(t.payload){const e=new le(t.payload);e.expiresIn>=0&&this._dispatcher.dispatch(e)}}else"NOOP"===t.code||this.dispatch("message",t)}}))}connect(t){this._ws=new WebSocket(t),this._ws.onopen=()=>{this._logger.debug("websocket open"),this.dispatch("open")},this._ws.onmessage=t=>e(this,void 0,void 0,(function*(){var s;if(null===(s=this._sdkState.websocket)||void 0===s?void 0:s.compression)if(t.data instanceof Blob){const s=new FileReader;s.readAsArrayBuffer(t.data),s.onloadend=()=>e(this,void 0,void 0,(function*(){const t=yield(i=s.result,e(void 0,void 0,void 0,(function*(){const e=Ai.ungzip(i);return String.fromCharCode.apply(null,e)})));var i;this._handleMessage(t)}))}else"string"==typeof t.data&&this._handleMessage(t.data);else this._handleMessage(t.data)})),this._ws.onerror=()=>{this._logger.debug("websocket error"),this.dispatch("error",o.networkError)},this._ws.onclose=()=>{this._logger.debug("websocket close"),this.dispatch("close")},this.lastActive=Date.now()}disconnect(){return new Promise((e=>{this._logger.debug("websocket disconnect"),this._ws&&this.connectionState!==exports.ConnectionState.CLOSED?(this._ws.onopen=pe,this._ws.onmessage=pe,this._ws.onerror=pe,this._ws.onclose=()=>{this.dispatch("close"),e()},this._ws.close(),this._ws=void 0):e()}))}send(e){if(!this._ws)throw o.connectionClosed;"PING"!==e.code?this.dispatch("ping-refresh"):this._logger.debug("send ping",e),this._ws.send(e.convertToMessage())}error(e){this._logger.debug("websocket error",e),this.dispatch("error",e)}}class Oi extends A{constructor({code:e,ackRequired:t,payload:s={}}){var i;super(),this.code=e,this.payload=s,this.requestId=null!==(i=this.payload.req_id)&&void 0!==i?i:C(),this.ackRequired=t,this.payload.req_id=this.requestId}convertToMessage(){return`${this.code}${JSON.stringify(this.payload)}\n`}}class Di extends A{constructor({all:e,custom_types:t,ts:s}){super(),this.all=e,this.customTypes=t,this.ts=s}}class Li{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}class Mi{constructor(e,{auth:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:r=!1}){this._ackStateMap=new Map,this._sdkState=s,this._dispatcher=i,this._logger=n,this.apiClient=new ue(e,{auth:t,sdkState:s,dispatcher:i,logger:n,useFetchCompat:r}),this.websocketClient=new Ri(e,{sdkState:s,dispatcher:i,logger:n}),this.websocketClient.on("message",(e=>{if(e.payload.unread_cnt&&this._dispatcher.dispatch(new Di(e.payload.unread_cnt)),e.requestId){if(this._ackStateMap.has(e.requestId)){const t=this._ackStateMap.get(e.requestId);"EROR"!==e.code?t.resolve(e):t.reject(new o({code:e.payload.code,message:e.payload.message}))}}else this._dispatcher.dispatch(e)})).on("close",(()=>{this._ackStateMap.forEach((e=>{e.reject(o.connectionClosed)})),this._ackStateMap.clear()}))}_sendApiRequest(t){return e(this,void 0,void 0,(function*(){return yield this.apiClient.send(t)}))}_sendWebsocketRequest(t){return e(this,void 0,void 0,(function*(){if(!this._sdkState.websocket)throw o.connectionRequired;const e=new Li;if(t.ackRequired){let s;const i=(i,n)=>{this._ackStateMap.has(t.requestId)&&(this._ackStateMap.delete(t.requestId),s&&(clearTimeout(s),s=null),i?(this._logger.debug("fail websocket request",i),e.reject(i)):(this._logger.debug("receive websocket ack",t.requestId),e.resolve(n)))};try{s=setTimeout((()=>i(o.noAckTimeout)),this._sdkState.websocket.responseTimeout),this._ackStateMap.set(t.requestId,{resolve:e=>i(void 0,e),reject:e=>i(e)}),this.websocketClient.send(t)}catch(e){i(e)}}else try{this.websocketClient.send(t),e.resolve()}catch(t){e.reject(t)}return e.promise}))}send(t){return e(this,void 0,void 0,(function*(){if(t instanceof oe)return yield this._sendApiRequest(t);if(t instanceof Oi)return yield this._sendWebsocketRequest(t);throw o.invalidParameters}))}cancel(e){this.apiClient.cancel(e)}cancelAll(){this.apiClient.cancelAll()}}exports.ConnectionStateType=void 0,(Ii=exports.ConnectionStateType||(exports.ConnectionStateType={}))[Ii.NONE=0]="NONE",Ii[Ii.INITIALIZED=1]="INITIALIZED",Ii[Ii.CONNECTING=2]="CONNECTING",Ii[Ii.CONNECTED=3]="CONNECTED",Ii[Ii.RECONNECTING=4]="RECONNECTING",Ii[Ii.INTERNAL_DISCONNECTED=5]="INTERNAL_DISCONNECTED",Ii[Ii.EXTERNAL_DISCONNECTED=6]="EXTERNAL_DISCONNECTED",Ii[Ii.LOGOUT=7]="LOGOUT";class Ui extends A{constructor({stateType:e}){super(),this.stateType=e}}class Pi{constructor(t,{auth:s,sdkState:i,dispatcher:n,logger:r,useFetchCompat:a=!1}){this._currentConnectionStateType=exports.ConnectionStateType.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new Mi(t,{auth:s,sdkState:i,dispatcher:n,logger:r,useFetchCompat:a}),this._auth=s,this._logger=r,this._dispatcher=n,this._dispatcher.on((t=>{if(t instanceof Ui){const{stateType:s}=t;switch(this._currentConnectionStateType=s,s){case exports.ConnectionStateType.CONNECTED:{const t=this._lazyCallQueue;this._lazyCallQueue=[],t.forEach((t=>e(this,void 0,void 0,(function*(){const{command:e,deferred:s,timeout:i}=t;clearTimeout(i);try{const t=yield this.send(e);s.resolve(t)}catch(e){s.reject(e)}}))));break}case exports.ConnectionStateType.INITIALIZED:case exports.ConnectionStateType.INTERNAL_DISCONNECTED:case exports.ConnectionStateType.EXTERNAL_DISCONNECTED:case exports.ConnectionStateType.LOGOUT:{const t=this._lazyCallQueue;this._lazyCallQueue=[],t.forEach((t=>e(this,void 0,void 0,(function*(){const{deferred:e,timeout:s}=t;clearTimeout(s),this._auth&&this._auth.hasSession?e.reject(o.connectionClosed):e.reject(o.connectionRequired)}))));break}}}}))}get isReady(){return this._currentConnectionStateType===exports.ConnectionStateType.CONNECTED}get isLazyCallActivated(){return this._currentConnectionStateType===exports.ConnectionStateType.CONNECTING||this._currentConnectionStateType===exports.ConnectionStateType.RECONNECTING}send(t){return e(this,void 0,void 0,(function*(){if(t instanceof Oi){if(this.isReady)return this._logger.debug("send websocket request",t),yield this.commandRouter.send(t);if(this.isLazyCallActivated){this._logger.debug("wait websocket request",t);const e=new Li;return this._lazyCallQueue.push({command:t,deferred:e,timeout:setTimeout((()=>this.timeout(t.requestId)),1e4)}),e.promise}throw this._logger.debug("fail websocket request"),o.connectionRequired}if(t instanceof oe){if(this._auth.hasSession)return this._logger.debug("send api request",t),yield this.commandRouter.send(t);if(this.isLazyCallActivated){this._logger.debug("wait api request",t);const e=new Li;return this._lazyCallQueue.push({command:t,deferred:e,timeout:setTimeout((()=>this.timeout(t.requestId)),1e4)}),e.promise}{const e=o.connectionRequired;throw this._logger.debug("fail api request",e),e}}throw o.invalidCommand}))}forceSend(t){return e(this,void 0,void 0,(function*(){return this._logger.debug("send forced request",t),yield this.commandRouter.send(t)}))}timeout(e){this._logger.debug("timeout request",e);const t=this._lazyCallQueue.findIndex((t=>t.command.requestId===e));t>-1&&(this._lazyCallQueue[t].deferred.reject(o.connectionRequired),this._lazyCallQueue.splice(t,1))}cancel(e){this._logger.debug("cancel api request",e),this.commandRouter.cancel(e)}cancelAll(){this._logger.debug("cancel all api requests"),this.commandRouter.cancelAll()}}const zi="sendbird@devicetokens";class Fi{constructor({type:e,token:t}){this.type=e,this.token=t}static payloadify(e){return N(I({type:e.type,token:e.token}))}}class qi extends oe{constructor({userId:e,authToken:t,expiringSession:s=!0}){super(),this.path=`${G}/${e}/session_key`,this.method=exports.APIRequestMethod.POST,this.params={token:t,expiring_session:!!s},this.requireAuth=!1}}class Gi extends Oi{constructor({authToken:e,expiringSession:t=!0,requestId:s=""}){super({code:"LOGI",payload:{token:e,expiring_session:t?1:0,req_id:s},ackRequired:!0})}}class Ki extends re{constructor(e,t){super(e,t);const{key:s}=t;this.key=s}}class Bi extends _e{constructor(e,t,s){var i;super(e,"LOGI",s),this.error=null,this.newKey=null,this.newKey=null!==(i=s.new_key)&&void 0!==i?i:null,this.error=s.error?new o(s.error):null}}class Hi extends A{}const Vi=t=>e(void 0,void 0,void 0,(function*(){return new Promise((e=>setTimeout(e,t)))}));class ji{calcTimeout(){return 0}}const $i=(t,s,i=new ji)=>e(void 0,void 0,void 0,(function*(){let e=0,n=null;const o=e=>n=null!=e?e:new Error("Halted"),r=()=>{e=0};for(;-1===s||ee(void 0,void 0,void 0,(function*(){try{yield t()}catch(e){if(!(e instanceof o))throw e;e.throwOutside()}})),Wi=new WeakMap;class Qi extends k{constructor({auth:e,cacheContext:t,sdkState:s,dispatcher:i,requestQueue:n,logger:o}){super(),this._currentConnectionStateType=exports.ConnectionStateType.INITIALIZED,this._isRefreshingAuthToken=!1,this._isRefreshingSessionKey=!1,this.currentUser=null,this.auth=e,this._cacheContext=t,this._sdkState=s,this._dispatcher=i,this._requestQueue=n,this._logger=o,this._deviceTokens=[],this._dispatcher.on((e=>{var t;if(e instanceof Ui){const{stateType:t}=e;this._currentConnectionStateType=t}else e instanceof le&&this.handler&&(e.invalidateSessionToken&&(this.auth.authToken=void 0),e.error&&(e.error.isSessionKeyExpiredError||e.error.isSessionTokenExpiredError)&&(this._logger.debug("session expired"),(null===(t=this.handler)||void 0===t?void 0:t.onSessionExpired)&&this.handler.onSessionExpired(),this.refresh()))}))}get ekey(){return Wi.get(this)}get deviceTokens(){return this._deviceTokens}get deviceTokenLastDeletedAt(){return this._deviceTokenLastDeletedAt}indexOfDeviceToken(e,t){return this._deviceTokens.findIndex((s=>s.type===e&&s.token===t))}hasDeviceToken(e,t){return this.indexOfDeviceToken(e,t)>=0}createRefreshWebsocketCommand(e,t){return new Gi({authToken:e,expiringSession:!0,requestId:t})}_refreshSessionKeyByWebSocket(t){return e(this,void 0,void 0,(function*(){const e=this.createRefreshWebsocketCommand(t),s=yield this._requestQueue.forceSend(e),{newKey:i,error:n}=s.as(Bi);if(n)throw n;this.auth.sessionKey=null!=i?i:this.auth.sessionKey}))}_refreshSessionKeyByApi(t){return e(this,void 0,void 0,(function*(){const s=new qi({userId:this._sdkState.userId,authToken:t,expiringSession:!0});yield $i((t=>e(this,void 0,void 0,(function*(){try{const e=yield this._requestQueue.forceSend(s),{key:t}=e.as(Ki);this.auth.sessionKey=t}catch(e){if(!this._isSessionRelatedError(e))throw e;t(e)}}))),3)}))}_refreshSessionKey(t,s=!0){return e(this,void 0,void 0,(function*(){if(this._currentConnectionStateType===exports.ConnectionStateType.CONNECTED)try{return yield this._refreshSessionKeyByWebSocket(t),void this.complete()}catch(e){if(this._isSessionRelatedError(e)&&s){const e=yield this._receiveNewAuthToken();return void(e?(this.auth.authToken=e,yield this._refreshSessionKey(this.auth.authToken,!1),this.complete()):(yield this.clear(),this.close()))}}try{yield this._refreshSessionKeyByApi(t),this.complete()}catch(e){if(!this._isSessionRelatedError(e))throw e;if(!s)throw e;{const e=yield this._receiveNewAuthToken();e?(this.auth.authToken=e,yield this._refreshSessionKeyByApi(this.auth.authToken),this.complete()):(yield this.clear(),this.close())}}}))}_receiveNewAuthToken(){const t=new Li;return Zi((()=>e(this,void 0,void 0,(function*(){this._isRefreshingAuthToken=!0,this.auth.clear();let e=null;const s=()=>{e&&(clearTimeout(e),e=null)};e=setTimeout((()=>{this._isRefreshingAuthToken=!1,t.reject()}),1e3*this._sdkState.sessionTokenRefreshTimeout),this.handler.onSessionTokenRequired?this.handler.onSessionTokenRequired((e=>{s(),this._isRefreshingAuthToken&&(this._isRefreshingAuthToken=!1,this.dispatch("refresh-authtoken"),t.resolve(e))}),(e=>{s(),this._isRefreshingAuthToken=!1,t.reject(e)})):t.resolve(null)})))),t.promise}_isSessionRelatedError(e){return e instanceof o&&(e.isSessionKeyExpiredError||e.isSessionTokenExpiredError||e.isSessionRevokedError)}get isSessionKeyRefreshing(){return this._isRefreshingSessionKey}get isRefreshingAuthToken(){return this._isRefreshingAuthToken}login(t){var s;return e(this,void 0,void 0,(function*(){const{key:e,ekey:i,userProfile:n,deviceTokenLastDeletedAt:o=0}=t;this.auth.sessionKey=e,Wi.set(this,i),this._deviceTokenCacheEnabled=null===(s=null==n?void 0:n.appInfo)||void 0===s?void 0:s.deviceTokenCache;const{preference:r}=this._cacheContext;if(this._deviceTokenCacheEnabled){const e=yield r.get(zi);!e||e.lastDeletedAtnew Fi(Fi.payloadify(e)))),this._deviceTokenLastDeletedAt=e.lastDeletedAt)}else yield r.remove(zi)}))}complete(){this.dispatch("refresh"),Zi((()=>e(this,void 0,void 0,(function*(){var e;this._logger.debug("session refreshed"),(null===(e=this.handler)||void 0===e?void 0:e.onSessionRefreshed)&&this.handler.onSessionRefreshed()}))))}error(t){Zi((()=>e(this,void 0,void 0,(function*(){var e;(null===(e=this.handler)||void 0===e?void 0:e.onSessionError)&&this.handler.onSessionError(t)}))))}close(){this.dispatch("close"),Zi((()=>e(this,void 0,void 0,(function*(){var e;this._logger.debug("session closed"),(null===(e=this.handler)||void 0===e?void 0:e.onSessionClosed)&&this.handler.onSessionClosed()}))))}refresh(){return e(this,void 0,void 0,(function*(){if(this.handler&&!this._isRefreshingSessionKey){if(this._isRefreshingSessionKey=!0,!this.auth.authToken)try{const e=yield this._receiveNewAuthToken();if(!e)return yield this.clear(),void(this._isRefreshingSessionKey=!1);this._logger.debug("session refreshing.."),this.auth.authToken=e}catch(e){const t=o.sessionTokenRequestFailed;throw this._dispatcher.dispatch(new Hi),this.error(t),this._isRefreshingSessionKey=!1,t}try{yield this._refreshSessionKey(this.auth.authToken),this._isRefreshingSessionKey=!1}catch(e){const t=o.sessionTokenRefreshFailed;throw this._dispatcher.dispatch(new Hi),this.error(t),this._isRefreshingSessionKey=!1,t}}}))}setDeviceToken(e,t){if(this._deviceTokenCacheEnabled){if(this.indexOfDeviceToken(e,t)<0)return this._deviceTokens.push(new Fi({type:e,token:t})),!0}return!1}unsetDeviceToken(e,t){if(this._deviceTokenCacheEnabled){const s=this.indexOfDeviceToken(e,t);s>=0&&this._deviceTokens.splice(s,1)}}unsetDeviceTokens(e){this._deviceTokenCacheEnabled&&(this._deviceTokens=e?this._deviceTokens.filter((t=>t.type!==e)):[])}setDeviceTokenDeletedAt(e){e>0&&(this._deviceTokenLastDeletedAt=e)}saveDeviceToken(){return e(this,void 0,void 0,(function*(){if(this._deviceTokenCacheEnabled){const{preference:e}=this._cacheContext;yield e.set(zi,{tokens:this._deviceTokens,lastDeletedAt:this._deviceTokenLastDeletedAt})}}))}clear(){return e(this,void 0,void 0,(function*(){this.currentUser=null,this.auth.clear(),this.close(),Wi.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,yield this.saveDeviceToken()}))}}class Yi{constructor(){this.type=exports.ConnectionStateType.NONE,this.name="none"}run(t){return e(this,void 0,void 0,(function*(){}))}onConnect(t,s){return e(this,void 0,void 0,(function*(){}))}onReconnect(t,{resetReconnectCount:s=!1}){return e(this,void 0,void 0,(function*(){}))}onDisconnect(t,{error:s=null,autoReconnect:i=!1}){return e(this,void 0,void 0,(function*(){}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){}))}onLogout(t){return e(this,void 0,void 0,(function*(){}))}}class Xi extends Yi{constructor(){super(...arguments),this.type=exports.ConnectionStateType.LOGOUT,this.name="logout"}run(t){return e(this,void 0,void 0,(function*(){const s=Date.now(),i=t.sdkState.userId;yield t.logout(),yield t.changeState(new on,s),Zi((()=>e(this,void 0,void 0,(function*(){t.connectionHandlers.forEach((e=>{e.onDisconnected&&e.onDisconnected(i)}))}))))}))}}class Ji extends Yi{constructor(){super(),this.type=exports.ConnectionStateType.EXTERNAL_DISCONNECTED,this.name="externaldisconnected"}run(t){return e(this,void 0,void 0,(function*(){yield t.disconnect()}))}onConnect(t,s){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.disconnect(),yield t.changeState(new nn({authToken:s}),e)}))}onReconnect(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new tn,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Xi,e)}))}}class en extends Yi{constructor({autoReconnect:e}){super(),this.type=exports.ConnectionStateType.INTERNAL_DISCONNECTED,this.name="internaldisconnected",this._autoReconnect=!1,this._autoReconnect=e}run(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.disconnect(),this._autoReconnect&&(yield t.changeState(new tn,e))}))}onConnect(t,s){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.disconnect(),yield t.changeState(new nn({authToken:s}),e)}))}onReconnect(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new tn,e)}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Ji,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Xi,e)}))}}class tn extends Yi{constructor(){super(...arguments),this.type=exports.ConnectionStateType.RECONNECTING,this.name="reconnecting",this._callbacks=[]}_halt(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=void 0)}_flushCallbacks(e){this._haltConnect=void 0,this._resetConnect=void 0,this._callbacks.forEach((t=>t(e)))}run(t){return e(this,void 0,void 0,(function*(){const s=Date.now(),i=new Li;this._callbacks.push((e=>e?i.reject(e):i.resolve())),Zi((()=>e(this,void 0,void 0,(function*(){t.connectionHandlers.forEach((e=>{e.onReconnectStarted&&e.onReconnectStarted()}))}))));try{const{reconnectMaxRetry:i,reconnectRetryStrategy:n}=t.sdkState.websocket;yield $i(((s,i)=>e(this,void 0,void 0,(function*(){this._haltConnect=s,this._resetConnect=i;try{yield t.connect()}catch(e){if(t.clearLoginTimer(),e instanceof o&&e.code===exports.SendbirdErrorCode.CONNECTION_CANCELED)return void s(e);throw e}}))),i,n),yield t.changeState(new sn,s),Zi((()=>e(this,void 0,void 0,(function*(){this._flushCallbacks(),t.connectionHandlers.forEach((e=>{e.onReconnectSucceeded&&e.onReconnectSucceeded()}))}))))}catch(i){if(n(i))throw i;i instanceof o&&i.code!==exports.SendbirdErrorCode.CONNECTION_CANCELED&&(yield t.changeState(new en({autoReconnect:!1}),s)),Zi((()=>e(this,void 0,void 0,(function*(){this._flushCallbacks(i),t.connectionHandlers.forEach((e=>{e.onReconnectFailed&&e.onReconnectFailed()}))}))))}return i.promise}))}onConnect(t,s){return e(this,void 0,void 0,(function*(){const e=new Li;return this._halt(o.connectionCanceled),t.cancelConnectForRetry(),this._callbacks.push((()=>{const i=Date.now();t.changeState(new nn({authToken:s}),i).then((()=>{e.resolve()})).catch((t=>{e.reject(t)}))})),e.promise}))}onReconnect(t,{resetReconnectCount:s=!1}){return e(this,void 0,void 0,(function*(){const e=new Li;return this._resetConnect&&s&&this._resetConnect(),this._callbacks.push((t=>t?e.reject(t):e.resolve())),e.promise}))}onDisconnect(t,{error:s=null,autoReconnect:i=!0}){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(o.connectionCanceled),yield t.changeState(new en({autoReconnect:i}),e)}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(o.connectionCanceled),yield t.changeState(new Ji,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(o.connectionCanceled),yield t.changeState(new Xi,e)}))}}class sn extends Yi{constructor(){super(...arguments),this.type=exports.ConnectionStateType.CONNECTED,this.name="connected"}onReconnect(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.disconnect(),yield t.changeState(new tn,e)}))}onDisconnect(t,{autoReconnect:s}){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new en({autoReconnect:s}),e)}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Ji,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new Xi,e)}))}}class nn extends Yi{constructor({authToken:e}){super(),this.type=exports.ConnectionStateType.CONNECTING,this.name="connecting",this._authToken="",this._callbacks=[],this._authToken=e}_halt(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=void 0)}_flushCallbacks(e){this._haltConnect=void 0,this._callbacks.forEach((t=>t(e)))}run(t){return e(this,void 0,void 0,(function*(){const s=Date.now(),i=new Li;this._callbacks.push((e=>e?i.reject(e):i.resolve()));try{yield $i((s=>e(this,void 0,void 0,(function*(){this._haltConnect=s;try{yield t.connect(this._authToken)}catch(e){if(t.clearLoginTimer(),e instanceof o&&e.code===exports.SendbirdErrorCode.CONNECTION_CANCELED)return void s(e);throw e}}))),t.sdkState.websocket.connectMaxRetry),yield t.changeState(new sn,s),Zi((()=>e(this,void 0,void 0,(function*(){this._flushCallbacks(),t.connectionHandlers.forEach((e=>{e.onConnected&&e.onConnected(t.sdkState.userId)}))}))))}catch(i){if(n(i))throw i;yield t.disconnect(),i instanceof o&&i.code!==exports.SendbirdErrorCode.CONNECTION_CANCELED&&(yield t.changeState(new on,s)),Zi((()=>e(this,void 0,void 0,(function*(){this._flushCallbacks(i)}))))}return i.promise}))}onConnect(t){return e(this,void 0,void 0,(function*(){const e=new Li;return this._callbacks.push((t=>t?e.reject(t):e.resolve())),e.promise}))}onDisconnect(t,{error:s=null,autoReconnect:i=!1}){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(null!=s?s:o.connectionCanceled),t.hasSession?yield t.changeState(new en({autoReconnect:i}),e):yield t.changeState(new Xi,e)}))}onDisconnectWebSocket(t){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(o.connectionCanceled),t.hasSession?yield t.changeState(new Ji,e):yield t.changeState(new Xi,e)}))}onLogout(t){return e(this,void 0,void 0,(function*(){const e=Date.now();this._halt(o.connectionCanceled),yield t.changeState(new Xi,e)}))}}class on extends Yi{constructor(){super(...arguments),this.type=exports.ConnectionStateType.INITIALIZED,this.name="initialized"}onConnect(t,s){return e(this,void 0,void 0,(function*(){const e=Date.now();yield t.changeState(new nn({authToken:s}),e)}))}}class rn extends Oi{constructor(){super({code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})}}class an{constructor({pingDelegate:e,sdkState:t,logger:s}){this.pingDelegate=e,this.sdkState=t,this._logger=s}get isWaiting(){return!!this._pingTimeoutTimer}ping(){var e;if(!this.sdkState.websocket)throw o.connectionRequired;const t=new rn;try{const s=null!==(e=this.sdkState.websocket.pongTimeout)&&void 0!==e?e:5e3;this._pingTimeoutTimer=setTimeout((()=>{this._logger.debug("pinger.ping() timeout"),this.pingDelegate.error()}),s),this.pingDelegate.send(t),this._logger.debug("pinger.ping()")}catch(e){this._logger.debug("pinger.ping() error",e),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0),this.pingDelegate.error()}return t}pong(){this._logger.debug("pinger.pong()"),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)}refreshTimer(){var e;if(!this.sdkState.websocket)throw o.connectionRequired;this._logger.debug("pinger.refreshTimer()");const t=null!==(e=this.sdkState.websocket.pingInterval)&&void 0!==e?e:15e3;this.stop(),this._pingTimer=setInterval((()=>{this.ping()}),t)}start(){this._logger.debug("pinger.start()"),this.refreshTimer(),this.ping()}stop(){this._logger.debug("pinger.stop()"),this._pingTimer&&(clearInterval(this._pingTimer),this._pingTimer=void 0),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)}}class ln{constructor(e){var t;this.lastUpdatedAt=null!==(t=e.last_updated_at)&&void 0!==t?t:0}static payloadify(e){return N(I({last_updated_at:e.lastUpdatedAt}))}}const dn=1048576;class cn{constructor(e={}){var t,s,i,n,o;this.emojiHash=e.emoji_hash||"",this.uploadSizeLimit=e.file_upload_size_limit?e.file_upload_size_limit*dn:Number.MAX_SAFE_INTEGER,this.useReaction=!!e.use_reaction,this.applicationAttributes=null!==(t=e.application_attributes)&&void 0!==t?t:[],this.premiumFeatureList=null!==(s=e.premium_feature_list)&&void 0!==s?s:[],this.deviceTokenCache=this.applicationAttributes.includes("sdk_device_token_cache"),this.enabledChannelMemberShipHistory=this.applicationAttributes.includes("channel_membership_history"),this.multipleFilesMessageFileCountLimit=null!==(i=e.multiple_file_send_max_size)&&void 0!==i?i:5,this.allowSdkStatsUpload=null===(n=e.allow_sdk_log_ingestion)||void 0===n||n,this.uikitConfigInfo=new ln(null!==(o=e.uikit_config)&&void 0!==o?o:{})}static payloadify(e){return N(I({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/dn,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,uikit_config:e.uikitConfigInfo?ln.payloadify(e.uikitConfigInfo):null}))}}class hn{constructor(e){this._iid="",this._iid=e}static payloadify(e){return{}}}class un extends oe{constructor({userId:e,metadata:t}){super(),this.method=exports.APIRequestMethod.POST,this.path=`${G}/${e}/metadata`,this.params={metadata:t}}}class _n extends re{constructor(e,t){super(e,t),this.metaData=t}}class pn extends oe{constructor({userId:e,metadata:t,upsert:s}){super(),this.method=exports.APIRequestMethod.PUT,this.path=`${G}/${e}/metadata`,this.params={metadata:t,upsert:s}}}class gn extends re{constructor(e,t){super(e,t),this.metadata=t}}class fn extends oe{constructor({userId:e,metadataKey:t}){super(),this.method=exports.APIRequestMethod.DELETE,this.path=`${G}/${e}/metadata/${t}`}}class En extends oe{constructor({userId:e}){super(),this.method=exports.APIRequestMethod.DELETE,this.path=`${G}/${e}/metadata`}}const vn=(e,t)=>{const s=JSON.parse(JSON.stringify(e));return s._iid&&delete s._iid,t&&t(s),s},mn=e=>({do:t=>{e||t()},throw:t=>{if(!e)throw t}});var Sn;exports.UserOnlineState=void 0,(Sn=exports.UserOnlineState||(exports.UserOnlineState={})).ONLINE="online",Sn.OFFLINE="offline",Sn.NON_AVAILABLE="nonavailable";class yn extends hn{constructor(e,t){var s,i,n,o,r,a,c,h,u,_,p,g;super(e),this.userId=null!==(i=null!==(s=t.guest_id)&&void 0!==s?s:t.user_id)&&void 0!==i?i:"",this.nickname=null!==(o=null!==(n=t.nickname)&&void 0!==n?n:t.name)&&void 0!==o?o:"",this.plainProfileUrl=null!==(a=null!==(r=t.profile_url)&&void 0!==r?r:t.image)&&void 0!==a?a:"",this.requireAuth=null!==(c=t.require_auth_for_profile_image)&&void 0!==c&&c,this.metaData=null!==(h=t.metadata)&&void 0!==h?h:{},this.connectionStatus=exports.UserOnlineState.NON_AVAILABLE,d(exports.UserOnlineState,t.is_online)?this.connectionStatus=t.is_online:l("boolean",t.is_online)&&(this.connectionStatus=t.is_online?exports.UserOnlineState.ONLINE:exports.UserOnlineState.OFFLINE),this.isActive=null===(u=t.is_active)||void 0===u||u,this.lastSeenAt=null!==(_=t.last_seen_at)&&void 0!==_?_:null,this.preferredLanguages=t.preferred_languages?[...t.preferred_languages]:null,this.friendDiscoveryKey=null!==(p=t.friend_discovery_key)&&void 0!==p?p:null,this.friendName=null!==(g=t.friend_name)&&void 0!==g?g:null}static payloadify(e){return N(I(Object.assign(Object.assign({},super.payloadify(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})))}get profileUrl(){const{sessionManager:e}=Un.of(this._iid);return this.requireAuth?`${this.plainProfileUrl}?auth=${e.ekey}`:this.plainProfileUrl}serialize(){return vn(this)}_isValidMetaData(e){return!Array.isArray(e)&&Object.keys(e).length>0&&Object.keys(e).map((t=>e[t])).every((e=>l("string",e)))}_applyMetaData(e,t=!1){Object.keys(e).forEach((s=>{t?delete this.metaData[s]:this.metaData[s]=e[s]}))}createMetaData(t){return e(this,void 0,void 0,(function*(){mn(this._isValidMetaData(t)).throw(o.invalidParameters);const{sdkState:e,requestQueue:s}=Un.of(this._iid),i=new un({userId:e.userId,metadata:t}),n=yield s.send(i),{metaData:r}=n.as(_n);return this._applyMetaData(r),this.metaData}))}updateMetaData(t,s=!1){return e(this,void 0,void 0,(function*(){mn(this._isValidMetaData(t)).throw(o.invalidParameters);const{sdkState:e,requestQueue:i}=Un.of(this._iid),n=new pn({userId:e.userId,metadata:t,upsert:s}),r=yield i.send(n),{metadata:a}=r.as(gn);return this._applyMetaData(a),this.metaData}))}deleteMetaData(t){return e(this,void 0,void 0,(function*(){mn(l("string",t)).throw(o.invalidParameters);const{sdkState:e,requestQueue:s}=Un.of(this._iid),i=new fn({userId:e.userId,metadataKey:t});return yield s.send(i),this._applyMetaData({[t]:!0},!0),this.metaData}))}deleteAllMetaData(){return e(this,void 0,void 0,(function*(){const{sdkState:e,requestQueue:t}=Un.of(this._iid),s=new En({userId:e.userId});yield t.send(s),this.metaData={}}))}}class wn extends A{constructor({userProfile:e}){super(),this.userProfile=e}}class bn{constructor(e,t){var s,i,n,o,r,a,l,d,c,h,u,_,p,g;this._iid=e,this.appInfo=new cn(t),this.user=new yn(e,t),this.connectedAt=null!==(s=t.login_ts)&&void 0!==s?s:0,this.firstConnectedAt=0,this.pingInterval=null!==(i=t.ping_interval)&&void 0!==i?i:15e3,this.pongTimeout=null!==(n=t.pong_timeout)&&void 0!==n?n:5e3,this.reconnectInterval=null!==(r=null===(o=t.reconnect)||void 0===o?void 0:o.interval)&&void 0!==r?r:3e3,this.reconnectMaxInterval=null!==(l=null===(a=t.reconnect)||void 0===a?void 0:a.max_interval)&&void 0!==l?l:6e4,this.reconnectRetryCount=null!==(c=null===(d=t.reconnect)||void 0===d?void 0:d.retry_cnt)&&void 0!==c?c:5,this.reconnectIntervalMultiple=null!==(u=null===(h=t.reconnect)||void 0===h?void 0:h.mul)&&void 0!==u?u:2,this.maxUnreadCountOnSuperGroup=null!==(_=t.max_unread_cnt_on_super_group)&&void 0!==_?_:100,this.profileImageEncryption=!!t.profile_image_encryption,this.concurrentCallLimit=null!==(p=t.concurrent_call_limit)&&void 0!==p?p:5,this.backOffDelay=null!==(g=t.back_off_delay)&&void 0!==g?g:100}static payloadify(e){return N(I(Object.assign(Object.assign(Object.assign({},yn.payloadify(e.user)),cn.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})))}apply(){const e=this.reconnectInterval,t=this.reconnectMaxInterval,s=this.reconnectIntervalMultiple,i=Un.of(this._iid);i.sdkState.websocket&&(i.sdkState.websocket.pingInterval=1e3*this.pingInterval,i.sdkState.websocket.pongTimeout=1e3*this.pongTimeout,i.sdkState.websocket.reconnectMaxRetry=this.reconnectRetryCount,i.sdkState.websocket.reconnectRetryStrategy={calcTimeout:i=>i>0?1e3*Math.min(e*Math.pow(s,i-1),t):10}),i.appInfo=this.appInfo,i.sessionManager.currentUser=this.user,i.connectedAt=this.connectedAt,this.firstConnectedAt||(i.firstConnectedAt=this.connectedAt),i.maxSuperGroupChannelUnreadCount=this.maxUnreadCountOnSuperGroup,i.concurrentCallLimit=this.concurrentCallLimit,i.backOffDelay=this.backOffDelay,i.dispatcher.dispatch(new wn({userProfile:this}))}}class Cn extends _e{constructor(e,t,s){var i,n,r;super(e,t,s),this.error=null,this.userProfile=new bn(e,s),this.deviceTokenLastDeletedAt=null!==(i=s.device_token_last_deleted_at)&&void 0!==i?i:0,this.key=null!==(n=s.key)&&void 0!==n?n:"",this.ekey=null!==(r=s.ekey)&&void 0!==r?r:"",this.error=s.error?new o(s):null}static asError(e){return new Cn("","LOGI",Object.assign({user_id:"",error:!0},e))}applyTo(t){return e(this,void 0,void 0,(function*(){if(this.error)throw this.error;{const e=Un.of(t);if(!e)throw o.lostInstance;{const{sessionManager:t}=e;yield t.login(this),this.userProfile.apply()}}}))}}class Tn extends A{constructor({request:e=!0,features:t={},options:s={}}){super(),this.request=e,this.features=Object.assign({localCache:!0},t),this.options=Object.assign({ingestion:!0},s)}}class kn extends k{constructor(e,{sdkState:t,cacheContext:s,connectionHandlers:i,sessionManager:n,websocketClient:r,dispatcher:a,logger:l,entryState:d=new on}){var c;super(),this._stateUpdatedAt=0,this._connectingAt=0,this._connectionRequestQueue=[],this._iid=e,this.sdkState=t,this.cacheContext=s,this.connectionHandlers=i,this._sessionManager=n,this._websocketClient=r,this._dispatcher=a,this._logger=l,this._currentState=d,(null===(c=this.sdkState.websocket)||void 0===c?void 0:c.pingerDisabled)||(this._pinger=new an({pingDelegate:{send:e=>this._websocketClient.send(e),error:e=>this._websocketClient.error(e)},sdkState:this.sdkState,logger:l})),this._websocketClient.on("open",(()=>{this._tryResolveConnectionRequest()})).on("message",(e=>{if("LOGI"===e.code)this.clearLoginTimer(),this._dispatcher.dispatch(e.as(Cn))})).on("ping-refresh",(()=>{var e;return null===(e=this._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(()=>{var e;return null===(e=this._pinger)||void 0===e?void 0:e.pong()})).on("error",(()=>{var e;return null===(e=this._pinger)||void 0===e?void 0:e.stop()})).on("close",(()=>{this._logiProcessingTimer=setTimeout((()=>{this._logiProcessingTimer=void 0,this._unresolvedLogi||this._rejectConnectionRequest(o.networkError)}),500)})),this._dispatcher.on((e=>{e instanceof Cn&&(this._unresolvedLogi=e,this._tryResolveConnectionRequest())}))}get currentState(){return this._currentState}get hasSession(){return this._sessionManager.auth.hasSession}changeState(t,s){return e(this,void 0,void 0,(function*(){return s>=this._stateUpdatedAt&&(this._currentState=t,this._stateUpdatedAt=s,this._dispatcher.dispatch(new Ui({stateType:t.type})),this._logger.debug(`connection state changes to ${t.name}`),yield this._currentState.run(this),!0)}))}_tryResolveConnectionRequest(){var t;return e(this,void 0,void 0,(function*(){const e=this._unresolvedLogi;if(this._websocketClient.isOpen&&e)if(this._unresolvedLogi=void 0,e.error)this._sessionManager.auth.authToken=void 0,(e.error.isSessionKeyExpiredError||e.error.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new le({reason:e.error.code})),this._rejectConnectionRequest(e.error);else{yield e.applyTo(this._iid);const{userProfile:s}=e;this._enableStatLog({request:s.appInfo.applicationAttributes.includes("allow_sdk_request_log_publish"),features:{localCache:s.appInfo.applicationAttributes.includes("allow_sdk_feature_local_cache_log_publish")},options:{ingestion:s.appInfo.allowSdkStatsUpload}}),this._statLogConnection(),null===(t=this._pinger)||void 0===t||t.start(),this._connectionRequestQueue.forEach((e=>e.resolve())),this._connectionRequestQueue=[],this.sdkState.appState="foreground"}}))}_rejectConnectionRequest(e){var t;if(null===(t=this._pinger)||void 0===t||t.stop(),this.clearLoginTimer(),this._connectionRequestQueue.length>0){const t=this._connectionRequestQueue;this._connectionRequestQueue=[],t.forEach((t=>t.reject(e))),this._statLogConnection(e)}}_url(e=""){var t,s,n;const{appId:o,appVersion:r,userId:a,extensions:l}=this.sdkState,{localCacheEnabled:d}=this.cacheContext,{auth:c}=this._sessionManager,h=null===(t=this.sdkState.websocket)||void 0===t?void 0:t.compression,u=null!==(s=this.sdkState.extensions)&&void 0!==s?s:{},_=!!u.sb_uikit,p=u.sb_syncmanager?`s${u.sb_syncmanager}`:"",g=u.sb_uikit?`u${u.sb_uikit}`:"",f=`JS/c${i.SDK_VERSION}/${p}/${g}`;return`${null===(n=this.sdkState.websocket)||void 0===n?void 0:n.host}/?p=JS&pv=${encodeURIComponent(i.OS_VERSION)}&sv=${encodeURIComponent(i.SDK_VERSION)}&ai=${o}${r?`&av=${r}`:""}${c.hasSession?`&key=${encodeURIComponent(c.sessionKey)}`:`&user_id=${encodeURIComponent(a)}&access_token=${encodeURIComponent(e)}`}&pmce=${h?1:0}&active=1&device_token_types=${encodeURIComponent(["gcm","huawei","apns"].join(","))}&SB-User-Agent=${f}&Request-Sent-Timestamp=${Date.now().toString()}&include_extra_data=${encodeURIComponent(String(["premium_feature_list","file_upload_size_limit","application_attributes","emoji_hash","multiple_file_send_max_size"]))}${this._sessionManager.handler?"&expiring_session=1":""}&use_local_cache=${d?1:0}&include_poll_details=1${_?"&uikit_config=1":""}`}_enableStatLog({request:e,features:t,options:s={}}){this._dispatcher.dispatch(new Tn({request:e,features:t,options:s}))}_statLogConnection(e){var t;this._dispatcher.dispatch(new de(new ce({type:exports.StatType.WEBSOCKET_CONNECT,data:{host_url:null===(t=this.sdkState.websocket)||void 0===t?void 0:t.host,success:!e,latency:Date.now()-this._connectingAt,error_code:null==e?void 0:e.code,error_description:null==e?void 0:e.message}})))}connect(t=""){var s;return e(this,void 0,void 0,(function*(){this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=void 0,this._rejectConnectionRequest(o.connectionCanceled));const e=this._url(t),i=new Li;return this._connectionRequestQueue.push(i),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((()=>{this._loginTimer=void 0,this._rejectConnectionRequest(o.loginTimeout)}),null===(s=this.sdkState.websocket)||void 0===s?void 0:s.responseTimeout),t&&(this._sessionManager.auth.authToken=t),this._websocketClient.connect(e)),i.promise}))}cancelConnectForRetry(){this._dispatcher.dispatch(Cn.asError(o.connectionRenew))}disconnect(){return e(this,void 0,void 0,(function*(){yield this._websocketClient.disconnect()}))}logout(){return e(this,void 0,void 0,(function*(){this.sdkState.userId=void 0,this._unresolvedLogi=void 0,yield this._sessionManager.clear(),yield this.disconnect()}))}clearLoginTimer(){this._loginTimer&&(clearTimeout(this._loginTimer),this._loginTimer=void 0)}}class xn{constructor(e,{sdkState:t,cacheContext:s,connectionHandlers:i,sessionManager:n,websocketClient:o,dispatcher:r,logger:a,disableWebSocketCloseEventHandling:l=!1}){this._disableWebSocketCloseEventHandling=!1,this._externalCalledWebSocketClose=!1,this._logger=a,this._disableWebSocketCloseEventHandling=l,this._context=new kn(e,{sdkState:t,cacheContext:s,connectionHandlers:i,sessionManager:n,websocketClient:o,dispatcher:r,logger:a}),this._sdkState=t,this._sessionManager=n,this._websocketClient=o}_registerEventDispatcher(){this._disableWebSocketCloseEventHandling||(this._clearEventDispatcher(),this._sessionEventDispatcherContext=this._sessionManager.on("refresh-authtoken",(()=>{this.isConnected||(this._logger.debug("try reconnect by session token refresh"),this.reconnect())})).on("refresh",(()=>{this.isConnecting||this.isConnected||(this._logger.debug("try reconnect by session key refresh"),this.reconnect())})),this._websocketEventDispatcherContext=this._websocketClient.on("close",(()=>{"foreground"!==this._sdkState.appState||this._externalCalledWebSocketClose||this._sessionManager.isRefreshingAuthToken||(this._logger.debug("try reconnect by websocket connection closed"),this.reconnect())})))}_clearEventDispatcher(){this._sessionEventDispatcherContext&&(this._sessionEventDispatcherContext.close(),this._sessionEventDispatcherContext=void 0),this._websocketEventDispatcherContext&&(this._websocketEventDispatcherContext.close(),this._websocketEventDispatcherContext=void 0)}get isConnected(){const{currentState:e}=this._context;return e.type===exports.ConnectionStateType.CONNECTED}get isConnecting(){const{currentState:e}=this._context;return e.type===exports.ConnectionStateType.CONNECTING||e.type===exports.ConnectionStateType.RECONNECTING}connect(t){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._externalCalledWebSocketClose=!1,yield e.onConnect(this._context,t),this._registerEventDispatcher()}))}reconnect(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._externalCalledWebSocketClose=!1,yield e.onReconnect(this._context,{})}))}resetAndReconnect(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._externalCalledWebSocketClose=!1,yield e.onReconnect(this._context,{resetReconnectCount:!0})}))}background(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._externalCalledWebSocketClose=!0,yield e.onDisconnect(this._context,{autoReconnect:!1})}))}disconnect(t){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;yield e.onDisconnect(this._context,{error:t,autoReconnect:!0})}))}disconnectWebSocket(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._externalCalledWebSocketClose=!0,yield e.onDisconnectWebSocket(this._context)}))}logout(){return e(this,void 0,void 0,(function*(){const{currentState:e}=this._context;this._clearEventDispatcher(),yield e.onLogout(this._context)}))}}class An extends ce{constructor({type:e,data:t,ts:s=Date.now()}){var i;super({type:e,data:t,ts:s}),this.date=new Date(s),this.key=`${i=this.date,`${i.getFullYear()}${String(i.getMonth()+1).padStart(2,"0")}${String(i.getDate()).padStart(2,"0")}`}_${e}`}}class Nn extends oe{constructor({deviceId:e,statLogs:t}){super(),this.method=exports.APIRequestMethod.POST,this.path=`${ee}`,this.params={device_id:e,log_entries:t.map((e=>ce.payloadify(e)))}}}const In=(e,t)=>{if(null!==e&&null!==t){const s=Object.keys(e),i=Object.keys(t),n=[...new Set([...s,...i])],o={};for(const s of n){const i=typeof e[s],n=typeof t[s];"undefined"===i?o[s]=t[s]:"undefined"===n?o[s]=e[s]:i!==n?o[s]=t[s]:"object"===i&&e[s]&&t[s]?o[s]=In(e[s],t[s]):o[s]=t[s]}return o}return t};var Rn,On;!function(e){e[e.PENDING=0]="PENDING",e[e.COLLECT_ONLY=1]="COLLECT_ONLY",e[e.ENABLED=2]="ENABLED",e[e.DISABLED=3]="DISABLED"}(Rn||(Rn={}));class Dn extends k{constructor({cacheContext:e,requestQueue:t,dispatcher:s,baseLimit:i=100,maxLimit:n=1e3,minLimit:o=10}){super(),this.queue=[],this.enabledState=Rn.PENDING,this.isFlushing=!1,this.generation=1,this.lastFlushedAt=0,this._collectRequestStat=!0,this._collectFeatureLocalCacheStat=!0,this.deviceId=C(),this.cacheContext=e,this.requestQueue=t,this.dispatcher=s,this.baseLimit=i,this.limit=i,this.maxLimit=n,this.minLimit=o}get isEnabled(){return this.enabledState===Rn.ENABLED}_arrangeStat(){const e=[];this._collectRequestStat&&e.push(...this.queue.filter((e=>e.type===exports.StatType.API_RESULT||e.type===exports.StatType.WEBSOCKET_CONNECT))),this._collectFeatureLocalCacheStat&&e.push(...this.queue.filter((e=>e.type===exports.StatType.FEATURE_LOCALCACHE))),this.queue=e}_save(){return e(this,void 0,void 0,(function*(){this.enabledState===Rn.ENABLED&&(yield this.cacheContext.preference.set(this.key,{deviceId:this.deviceId,statLogs:this.queue.map((e=>ce.payloadify(e))),generation:this.generation++,lastFlushedAt:this.lastFlushedAt}),this.dispatch("save",[...this.queue]))}))}_flush(){return e(this,void 0,void 0,(function*(){if(this.isEnabled&&!this.isFlushing){this.isFlushing=!0;try{this._arrangeStat();const e=this.queue.filter((e=>{if(e instanceof An){const t=new Date,[s,i]=[e.date.getFullYear(),t.getFullYear()];if(s!(e instanceof An))),s=[...e,...t].slice(0,Math.min(this.limit,this.maxLimit));if(s.length>0){const i=new Nn({deviceId:this.deviceId,statLogs:s});yield this.requestQueue.send(i),this.dispatch("flush",s),this.queue=[...e,...t].slice(s.length),yield this._save()}this.limit=this.baseLimit,this.lastFlushedAt=Date.now()}catch(e){e instanceof o&&(e.code===exports.SendbirdErrorCode.STAT_LOG_NOT_ALLOWED?(yield this.clear(),this.enabledState=Rn.DISABLED):e.code===exports.SendbirdErrorCode.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Rn.COLLECT_ONLY)),this.limit=this.limit+20}finally{this.isFlushing=!1}}}))}init(t){return e(this,void 0,void 0,(function*(){this.key=t;const e=yield this.cacheContext.preference.get(this.key);if(e&&(this.deviceId=e.deviceId,this.queue=e.statLogs.map((e=>new ce({type:e.stat_type,ts:e.ts,data:e.data}))),this.generation=e.generation,this.lastFlushedAt=e.lastFlushedAt,Date.now()-this.lastFlushedAt>=108e5&&this.queue.length>=this.minLimit)){const e=Math.min(Math.floor(18e4*Math.random()),100);yield Vi(e),yield this._flush()}this.commandEventContext||(this.commandEventContext=this.dispatcher.on((e=>{if(e instanceof de){const{statLog:t}=e;this.put(t)}else if(e instanceof Tn){const{request:t,features:s,options:i}=e;this._collectRequestStat=t,this._collectFeatureLocalCacheStat=null==s?void 0:s.localCache,this._arrangeStat(),this._collectRequestStat||this._collectFeatureLocalCacheStat?this.enabledState=i.ingestion?Rn.ENABLED:Rn.COLLECT_ONLY:this.enabledState=Rn.DISABLED,this.isEnabled?this.queue.length>=this.limit&&this._flush():this.clear()}})))}))}put(t){return e(this,void 0,void 0,(function*(){if(this.enabledState!==Rn.DISABLED){if(t instanceof An){if(this._collectFeatureLocalCacheStat){const[e]=this.queue.filter((e=>e instanceof An&&e.key===t.key));e?e.data=In(e.data,t.data):this.queue.push(t)}}else this._collectRequestStat&&this.queue.push(t);yield this._save(),this.queue.length>=this.limit&&(yield this._flush())}}))}clear(){return e(this,void 0,void 0,(function*(){this.queue=[],this.generation=1,yield this._save()}))}close(){this.commandEventContext&&(this.commandEventContext.close(),this.commandEventContext=void 0)}}exports.LogLevel=void 0,(On=exports.LogLevel||(exports.LogLevel={}))[On.NONE=0]="NONE",On[On.VERBOSE=1]="VERBOSE",On[On.DEBUG=2]="DEBUG",On[On.INFO=3]="INFO",On[On.WARN=4]="WARN",On[On.ERROR=5]="ERROR";class Ln{constructor(){this.level=exports.LogLevel.WARN}verbose(...e){this.level<=exports.LogLevel.VERBOSE&&console.log("[verbose]",...e)}debug(...e){this.level<=exports.LogLevel.DEBUG&&console.log("[debug]",...e)}info(...e){this.level<=exports.LogLevel.INFO&&console.log("[info]",...e)}warn(...e){this.level<=exports.LogLevel.WARN&&console.warn("[warn]",...e)}error(...e){this.level<=exports.LogLevel.ERROR&&console.error("[error]",...e)}}const Mn={};class Un{constructor(e,t){var s,n,o,r,a,l,d,c,h,u;if(this.connectedAt=0,this.firstConnectedAt=0,this.connectionHandlers=new Map,this.userEventHandlers=new Map,!Mn[e]){Mn[e]=this;const p=null!==(s=t.options)&&void 0!==s?s:new _,g=this.sdkState={appId:t.appId,appVersion:null!==(n=t.appVersion)&&void 0!==n?n:"",appState:"foreground",userId:void 0,extensions:{},api:{host:null!==(o=t.apiHost)&&void 0!==o?o:`https://api-${t.appId}.sendbird.com`},websocket:{host:null!==(r=t.websocketHost)&&void 0!==r?r:`wss://ws-${t.appId}.sendbird.com`,pingerDisabled:!!t.noPingpong,pingInterval:void 0,pongTimeout:void 0,connectMaxRetry:2,compression:!0,reconnectMaxRetry:-1,reconnectRetryStrategy:new ji,responseTimeout:p.websocketResponseTimeout},sessionTokenRefreshTimeout:p.sessionTokenRefreshTimeout};this.appInfo=void 0,this.subscribedUnreadMessageCount={all:0,customTypes:{},ts:0};const E=this.logger=new Ln;this.logger.level=null!==(a=t.logLevel)&&void 0!==a?a:exports.LogLevel.WARN,this.connectedAt=0,this.firstConnectedAt=0,this.connectionHandlers=new Map,this.userEventHandlers=new Map;const v=this.cacheContext=new f({encryption:t.encryption,store:t.store,localCacheEnabled:null!==(l=t.localCacheEnabled)&&void 0!==l&&l,localCacheConfig:null!==(d=t.localCacheConfig)&&void 0!==d?d:new w});this.debugMode=null!==(c=t.debugMode)&&void 0!==c&&c,this.maxSuperGroupChannelUnreadCount=i.DEFAULT_MAX_UNREAD_COUNT_OF_SUPER_GROUP_CHANNEL,this.useMemberInfoInMessage=p.useMemberInfoInMessage,this.typingIndicatorInvalidateTime=p.typingIndicatorInvalidateTime,this.typingIndicatorThrottle=p.typingIndicatorThrottle,this.concurrentCallLimit=void 0,this.backOffDelay=void 0;const m=this.dispatcher=new x,S=new b;this.requestQueue=new Pi(e,{auth:S,sdkState:g,dispatcher:m,logger:E,useFetchCompat:t.useFetchCompat}),this.sessionManager=new Qi({auth:S,cacheContext:v,sdkState:g,dispatcher:m,requestQueue:this.requestQueue,logger:E}),this.connectionManager=new xn(e,{sdkState:g,cacheContext:this.cacheContext,connectionHandlers:this.connectionHandlers,dispatcher:m,sessionManager:this.sessionManager,websocketClient:this.requestQueue.commandRouter.websocketClient,disableWebSocketCloseEventHandling:null!==(h=t.disableWebSocketCloseEventHandling)&&void 0!==h&&h,logger:E}),this.statLogCollector=new Dn({cacheContext:this.cacheContext,requestQueue:this.requestQueue,dispatcher:m}),this.appStateToggleEnabled=null===(u=t.appStateToggleEnabled)||void 0===u||u}return Mn[e]}static of(e){if(Mn[e])return Mn[e];throw o.lostInstance}static clear(e){Mn[e]&&delete Mn[e]}hasExtension(e){return this.sdkState.extensions&&this.sdkState.extensions[e]}}var Pn;exports.PollStatus=void 0,(Pn=exports.PollStatus||(exports.PollStatus={})).OPEN="open",Pn.CLOSED="closed";const zn=e=>{switch(e){case"open":return exports.PollStatus.OPEN;case"closed":return exports.PollStatus.CLOSED;default:return null}};class Fn extends hn{constructor(e,t){var s,i,n,o,r,a,l;super(e),this.pollId=0,this.id=0,this.text=null,this.voteCount=0,this.createdBy=null,this.createdAt=0,this.updatedAt=0,this._lastVotedAt=0,this.pollId=null!==(s=t.poll_id)&&void 0!==s?s:0,this.id=null!==(i=t.id)&&void 0!==i?i:0,this.text=null!==(n=t.text)&&void 0!==n?n:null,this.voteCount=null!==(o=t.vote_count)&&void 0!==o?o:0,this.createdBy=null!==(r=t.created_by)&&void 0!==r?r:null,this.createdAt=null!==(a=t.created_at)&&void 0!==a?a:0,this.updatedAt=null!==(l=t.updated_at)&&void 0!==l?l:0}static payloadify(e){return N(I(Object.assign(Object.assign({},super.payloadify(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})))}}var qn;exports.MessageEventSource=void 0,(qn=exports.MessageEventSource||(exports.MessageEventSource={})).UNKNOWN="UNKNOWN",qn.EVENT_MESSAGE_SENT_SUCCESS="EVENT_MESSAGE_SENT_SUCCESS",qn.EVENT_MESSAGE_SENT_FAILED="EVENT_MESSAGE_SENT_FAILED",qn.EVENT_MESSAGE_SENT_PENDING="EVENT_MESSAGE_SENT_PENDING",qn.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",qn.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",qn.EVENT_MESSAGE_DELETED="EVENT_MESSAGE_DELETED",qn.EVENT_MESSAGE_READ="EVENT_MESSAGE_READ",qn.EVENT_MESSAGE_DELIVERED="EVENT_MESSAGE_DELIVERED",qn.EVENT_MESSAGE_REACTION_UPDATED="EVENT_MESSAGE_REACTION_UPDATED",qn.EVENT_MESSAGE_THREADINFO_UPDATED="EVENT_MESSAGE_THREADINFO_UPDATED",qn.EVENT_MESSAGE_OFFSET_UPDATED="EVENT_MESSAGE_OFFSET_UPDATED",qn.REQUEST_MESSAGE="REQUEST_MESSAGE",qn.EVENT_POLL_UPDATED="EVENT_POLL_UPDATED",qn.EVENT_POLL_VOTED="EVENT_POLL_VOTED",qn.SYNC_POLL_CHANGELOGS="SYNC_POLL_CHANGELOGS",qn.REQUEST_RESEND_MESSAGE="REQUEST_RESEND_MESSAGE",qn.REQUEST_THREADED_MESSAGE="REQUEST_THREADED_MESSAGE",qn.REQUEST_MESSAGE_CHANGELOGS="REQUEST_MESSAGE_CHANGELOGS",qn.SYNC_MESSAGE_FILL="SYNC_MESSAGE_FILL",qn.SYNC_MESSAGE_BACKGROUND="SYNC_MESSAGE_BACKGROUND",qn.SYNC_MESSAGE_CHANGELOGS="SYNC_MESSAGE_CHANGELOGS",qn.LOCAL_MESSAGE_PENDING_CREATED="LOCAL_MESSAGE_PENDING_CREATED",qn.LOCAL_MESSAGE_FAILED="LOCAL_MESSAGE_FAILED",qn.LOCAL_MESSAGE_CANCELED="LOCAL_MESSAGE_CANCELED",qn.LOCAL_MESSAGE_RESEND_STARTED="LOCAL_MESSAGE_RESEND_STARTED";class Gn{constructor(e,t){var s;this.limit=20,this._isLoading=!1,this._hasNext=!0,this._token="",this._iid=e,this.limit=null!==(s=t.limit)&&void 0!==s?s:20}get hasNext(){return this._hasNext}get isLoading(){return this._isLoading}_validate(){return l("number",this.limit)&&this.limit>0}}exports.APIRequestCommand=oe,exports.APIResponseCommand=re,exports.API_PATH_EMOJIS=W,exports.API_PATH_EMOJI_CATEGORIES=Q,exports.API_PATH_GROUP_CHANNELS=B,exports.API_PATH_GROUP_CHANNELS_INTERNAL=H,exports.API_PATH_OPEN_CHANNELS=V,exports.API_PATH_OPEN_CHANNELS_INTERNAL=j,exports.API_PATH_POLLS=Y,exports.API_PATH_REPORT=Z,exports.API_PATH_SCHEDULED_MESSAGES=X,exports.API_PATH_SEARCH=$,exports.API_PATH_UIKIT_CONFIGURATION=J,exports.API_PATH_UPLOAD=K,exports.API_PATH_USERS=G,exports.BaseCommand=A,exports.BaseListQuery=Gn,exports.CachedChannelInfo=class{constructor({channel:e,cachedMessageCount:t}){this._cachedMessageCount=0,this._channel=e,this._cachedMessageCount=t}get channel(){return this._channel}get cachedMessageCount(){return this._cachedMessageCount}},exports.ChannelDataListQuery=class extends Gn{constructor(e,t,s,i){super(e,i),this.channelUrl=t,this.channelType=s}_validate(){return super._validate()&&l("string",this.channelUrl)&&d(exports.ChannelType,this.channelType)}},exports.ConnectionStateChangeCommand=Ui,exports.DEFAULT_ENCRYPTION=p,exports.DEFAULT_MULTIPLE_FILES_MESSAGE_FILE_COUNT_LIMIT=5,exports.DailyRecordStatLog=An,exports.Deferred=Li,exports.EventDispatcher=k,exports.InstancedObject=hn,exports.LocalCacheConfig=w,exports.MessageRemoveEventCommand=class extends A{constructor({messageIds:e,source:t,isWebSocketEventComing:s=!1}){super(),this.messageIds=e,this.source=t,this.isWebSocketEventComing=s}},exports.MessageUpdateEventCommand=class extends A{constructor({messages:e,source:t,isWebSocketEventComing:s=!1}){super(),this.messages=e,this.source=t,this.isWebSocketEventComing=s}},exports.Module=class{init(e,{sdkState:t,dispatcher:s,sessionManager:i,requestQueue:n,logger:o,onlineDetector:r,cacheContext:a}){this._iid=e,this._cacheContext=a,this._sdkState=t,this._dispatcher=s,this._sessionManager=i,this._requestQueue=n,this._logger=o}},exports.POLL_REMOVED_STATUS="removed",exports.Poll=class extends hn{constructor(e,t){var s,i,n,o,r,a,l,d,c,h,u,_,p;super(e),this.id=0,this.title=null,this.createdAt=0,this.updatedAt=0,this.closeAt=-1,this.status=exports.PollStatus.CLOSED,this.messageId=0,this.data=null,this.voterCount=-1,this.options=[],this.createdBy=null,this.allowUserSuggestion=!1,this.allowMultipleVotes=!1,this.votedPollOptionIds=[],this.id=null!==(s=t.id)&&void 0!==s?s:0,this.title=null!==(i=t.title)&&void 0!==i?i:null,this.createdAt=null!==(n=t.created_at)&&void 0!==n?n:0,this.updatedAt=null!==(o=t.updated_at)&&void 0!==o?o:0,this.closeAt=null!==(r=t.close_at)&&void 0!==r?r:-1,this.status=null!==(a=zn(t.status))&&void 0!==a?a:exports.PollStatus.CLOSED,this.messageId=null!==(l=t.message_id)&&void 0!==l?l:0,this.data=null!==(d=t.data)&&void 0!==d?d:null,this.voterCount=null!==(c=t.voter_count)&&void 0!==c?c:-1,this.options=t.options?t.options.map((e=>new Fn(this._iid,e))):[],this.createdBy=null!==(h=t.created_by)&&void 0!==h?h:null,this.allowUserSuggestion=null!==(u=t.allow_user_suggestion)&&void 0!==u&&u,this.allowMultipleVotes=null!==(_=t.allow_multiple_votes)&&void 0!==_&&_,this.votedPollOptionIds=null!==(p=t.voted_option_ids)&&void 0!==p?p:[]}_applyPollUpdatePayload(e){var t,s,i,n,o,r,a,l;this.title=null!==(t=e.title)&&void 0!==t?t:this.title,this.updatedAt=null!==(s=e.updated_at)&&void 0!==s?s:this.updatedAt,this.closeAt=null!==(i=e.close_at)&&void 0!==i?i:this.closeAt,this.status=null!==(n=zn(e.status))&&void 0!==n?n:this.status,this.data=null!==(o=e.data)&&void 0!==o?o:this.data,this.voterCount=null!==(r=e.voter_count)&&void 0!==r?r:this.voterCount,e.options&&(this.options=e.options.map((e=>new Fn(this._iid,e))),this.votedPollOptionIds=e.options.filter((e=>e.vote_count>0)).map((e=>e.id))),this.allowUserSuggestion=null!==(a=e.allow_user_suggestion)&&void 0!==a?a:this.allowUserSuggestion,this.allowMultipleVotes=null!==(l=e.allow_multiple_votes)&&void 0!==l?l:this.allowMultipleVotes}static payloadify(e){return N(I(Object.assign(Object.assign({},super.payloadify(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((e=>Fn.payloadify(e))),created_by:e.createdBy,allow_user_suggestion:e.allowUserSuggestion,allow_multiple_votes:e.allowMultipleVotes,voted_option_ids:e.votedPollOptionIds})))}applyPollUpdateEvent(e){const t=e._payload.poll;return!(!t||this.id!==t.id||t.updated_ate.id)),i=e._payload,n=Math.floor(i.ts/1e3);return i.updated_vote_counts.forEach((e=>{const i=s.indexOf(e.option_id);if(i>-1){const s=t[i];n>=s._lastVotedAt&&(s.voteCount=e.vote_count,s._lastVotedAt=n)}})),i.req_id&&i.voted_option_ids&&(this.votedPollOptionIds=i.voted_option_ids),"number"==typeof i.voter_count&&(this.voterCount=i.voter_count),!0}serialize(){return vn(this)}},exports.PollChangeLogEventCommand=class extends A{constructor({polls:e,source:t}){super(),this.polls=e,this.source=t}},exports.PollOption=Fn,exports.PollUpdateInternalEventCommand=class extends A{constructor({event:e,source:t}){super(),this.event=e,this.source=t}},exports.PollVoteInternalEventCommand=class extends A{constructor({event:e,source:t}){super(),this.event=e,this.source=t}},exports.SendbirdChatOptions=_,exports.SendbirdError=o,exports.SessionExpiredCommand=le,exports.SubscribedUnreadMessageCountUpdateCommand=Di,exports.UIKitConfigInfo=ln,exports.UnsentMessageRemoveEventCommand=class extends A{constructor({reqId:e,source:t}){super(),this.reqId=e,this.source=t}},exports.User=yn,exports.UserProfile=bn,exports.UserProfileUpdateCommand=wn,exports.Vault=Un,exports.WebSocketEventCommand=_e,exports.WebSocketRequestCommand=Oi,exports.__awaiter=e,exports.__rest=function(e,t){var s={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(s[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(i=Object.getOwnPropertySymbols(e);n{var i,n,o,r;const a=te(null!==(i=e.mentionType)&&void 0!==i?i:null,null!==(n=e.mentionedUserIds)&&void 0!==n?n:[],s),l=te(null!==(o=t.mentionType)&&void 0!==o?o:null,null!==(r=t.mentionedUserIds)&&void 0!==r?r:[],s);return!a&&l?1:a&&!l?-1:0},exports.checkIfMentioned=te,exports.deepEqual=(e,t)=>{if(e!==t){const s=Object.assign({},e),i=Object.assign({},t);return(!s.hasOwnProperty("messageId")||!i.hasOwnProperty("messageId")||s.messageId===i.messageId)&&((!s.hasOwnProperty("reqId")||!i.hasOwnProperty("reqId")||s.reqId===i.reqId)&&(s.hasOwnProperty("messageId")&&delete s.messageId,s.hasOwnProperty("reqId")&&delete s.reqId,i.hasOwnProperty("messageId")&&delete i.messageId,i.hasOwnProperty("reqId")&&delete i.reqId,JSON.stringify(s)===JSON.stringify(i)))}return!0},exports.deserialize=(e,t)=>{const s=JSON.parse(JSON.stringify(e));return t&&t(s),s},exports.deundefined=N,exports.getChannelApiPathByType=e=>{switch(e){case exports.ChannelType.GROUP:return B;case exports.ChannelType.OPEN:return V;default:return null}},exports.getReportApiPathByType=e=>{switch(e){case exports.ChannelType.GROUP:return`${Z}/group_channels`;case exports.ChannelType.OPEN:return`${Z}/open_channels`;default:return null}},exports.hasSameMembers=(e,t)=>{if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;const s=[...e].sort(),i=[...t].sort();for(let e=0;ee>0&&a.indexOf(e)>=0,exports.isEnumOf=d,exports.isFile=u,exports.isReactNative=he,exports.isResendableError=e=>e>0&&r.indexOf(e)>=0,exports.isThrowingOutside=n,exports.isTypeOf=l,exports.noop=pe,exports.parsePollStatusPayload=zn,exports.runAsCallback=Zi,exports.runOrNothing=t=>e(void 0,void 0,void 0,(function*(){try{yield t()}catch(e){}})),exports.serialize=vn,exports.shouldGiveEvent=e=>e.startsWith("EVENT_")||e.startsWith("LOCAL_MESSAGE_")||e===exports.MessageEventSource.SYNC_MESSAGE_FILL||e===exports.MessageEventSource.SYNC_MESSAGE_CHANGELOGS||e===exports.MessageEventSource.SYNC_POLL_CHANGELOGS,exports.sleep=Vi,exports.undefineNullProps=I,exports.unless=mn,exports.uuid=C,exports.validateOptionTexts=e=>h("string",e)&&e.every((e=>""!==e.trim())),exports.validatePollData=e=>!e||!!e.text&&l("string",e.text),exports.version=s; diff --git a/cjs/lib/__bundle-481ecf03.js b/cjs/lib/__bundle-481ecf03.js new file mode 100644 index 0000000..9bb5757 --- /dev/null +++ b/cjs/lib/__bundle-481ecf03.js @@ -0,0 +1 @@ +"use strict";var e=require("./__bundle-032c97c6.js");class t extends e.APIRequestCommand{constructor({title:t,optionTexts:s,data:n,allowUserSuggestion:o,allowMultipleVotes:l,closeAt:i}){super(),this.method=e.APIRequestMethod.POST,this.path=e.API_PATH_POLLS,this.params={title:t,options:s,data:n,allow_user_suggestion:o,allow_multiple_votes:l,close_at:i}}}class s extends e.APIResponseCommand{constructor(t,s){super(t,s),this.poll=new e.Poll(t,s)}}class n extends e.APIRequestCommand{constructor({channelUrl:t,channelType:s,pollId:n}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_POLLS}/${encodeURIComponent(n)}`,this.params={channel_url:t,channel_type:s}}}class o extends e.APIResponseCommand{constructor(t,s){super(t,s),this.poll=new e.Poll(t,s)}}class l extends e.APIRequestCommand{constructor({channelUrl:t,channelType:s,pollId:n,pollOptionId:o}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_POLLS}/${encodeURIComponent(n)}/options/${encodeURIComponent(o)}`,this.params={channel_url:t,channel_type:s}}}class i extends e.APIResponseCommand{constructor(t,s){super(t,s),this.pollOption=new e.PollOption(t,s)}}class a extends e.APIRequestCommand{constructor({channelType:t,channelUrl:s,timestamp:n,token:o}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.getChannelApiPathByType(t)}/${encodeURIComponent(s)}/polls/changelogs`,this.params=e.deundefined({change_ts:n,token:o})}}class r extends e.APIResponseCommand{constructor(t,s){super(t,s),this.updatedPolls=s.updated.map((s=>((t,s)=>new e.Poll(t,s))(t,s))),this.deletedPollIds=s.deleted.map((e=>e)),this.hasMore=s.has_more,this.nextToken=s.next}}const d={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},p=t=>e.isTypeOf("string",t.title)&&e.validateOptionTexts(t.optionTexts)&&e.validatePollData(t.data)&&e.isTypeOf("boolean",t.allowUserSuggestion,!0)&&e.isTypeOf("boolean",t.allowMultipleVotes,!0)&&e.isTypeOf("number",t.closeAt,!0),h={channelUrl:"",channelType:e.ChannelType.BASE,pollId:0,pollOptionId:0},u=t=>e.isTypeOf("string",t.channelUrl)&&""!==t.channelUrl&&e.isEnumOf(e.ChannelType,t.channelType)&&e.isTypeOf("number",t.pollId)&&t.pollId>0&&e.isTypeOf("number",t.pollOptionId)&&t.pollOptionId>0,c={channelUrl:"",channelType:e.ChannelType.BASE,pollId:0},m=t=>e.isTypeOf("string",t.channelUrl)&&""!==t.channelUrl&&e.isEnumOf(e.ChannelType,t.channelType)&&e.isTypeOf("number",t.pollId),_={};class P extends e.APIRequestCommand{constructor({channelUrl:t,channelType:s,token:n,limit:o}){super(),this.method=e.APIRequestMethod.GET,this.path=e.API_PATH_POLLS,this.params={channel_url:t,channel_type:s,token:n,limit:o}}}class I extends e.APIResponseCommand{constructor(t,s){var n;super(t,s),this.polls=(null!==(n=s.polls)&&void 0!==n?n:[]).map((s=>new e.Poll(t,s))),this.token=s.next}}class g extends e.ChannelDataListQuery{constructor(e,t){super(e,t.channelUrl,t.channelType,t)}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:t}=e.Vault.of(this._iid),s=new P(Object.assign(Object.assign({},this),{token:this._token})),n=yield t.send(s),{polls:o,token:l}=n.as(I);return this._token=l,this._hasNext=!!l,this._isLoading=!1,o}return[]}throw e.SendbirdError.invalidParameters}))}}class y extends e.APIRequestCommand{constructor({channelUrl:t,channelType:s,pollId:n,pollOptionId:o,token:l,limit:i}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_POLLS}/${encodeURIComponent(n)}/options/${encodeURIComponent(o)}/voters`,this.params={channel_url:t,channel_type:s,token:l,limit:i}}}class v extends e.APIResponseCommand{constructor(t,s){var n;super(t,s),this.voters=(null!==(n=s.voters)&&void 0!==n?n:[]).map((s=>new e.User(t,s))),this.token=s.next}}class O extends e.ChannelDataListQuery{constructor(e,t){super(e,t.channelUrl,t.channelType,t),this.pollId=t.pollId,this.pollOptionId=t.pollOptionId}_validate(){return super._validate()&&e.isTypeOf("number",this.pollId)&&e.isTypeOf("number",this.pollOptionId)}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:t}=e.Vault.of(this._iid),s=new y(Object.assign(Object.assign({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),n=yield t.send(s),{voters:o,token:l}=n.as(v);return this._token=l,this._hasNext=!!l,this._isLoading=!1,o}return[]}throw e.SendbirdError.invalidParameters}))}}exports.PollCreateParamsDefault=d,exports.PollListQuery=g,exports.PollManager=class{constructor(e,{sdkState:t,dispatcher:s,sessionManager:n,requestQueue:o,logger:l}){this._iid=e,this._sdkState=t,this._sessionManager=n,this._requestQueue=o,this._dispatcher=s,this._logger=l,_[e]=this}static of(e){return _[e]}buildPollFromSerializedData(t){const s=e.deserialize(t);return new e.Poll(this._iid,e.Poll.payloadify(s))}get(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(m(t)).throw(e.SendbirdError.invalidParameters);const s=new n(Object.assign({},t)),l=yield this._requestQueue.send(s),{poll:i}=l.as(o);return i}))}create(n){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(p(n)).throw(e.SendbirdError.invalidParameters);const o=new t(Object.assign({},n)),l=yield this._requestQueue.send(o),{poll:i}=l.as(s);return i}))}getOption(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(u(t)).throw(e.SendbirdError.invalidParameters);const s=new l(Object.assign({},t)),n=yield this._requestQueue.send(s),{pollOption:o}=n.as(i);return o}))}getPollChangeLogs(t,s,n,o=e.MessageEventSource.SYNC_POLL_CHANGELOGS){return e.__awaiter(this,void 0,void 0,(function*(){const l=new a(e.undefineNullProps({channelType:s,channelUrl:t,timestamp:"number"==typeof n?n:null,token:"string"==typeof n?n:null})),i=yield this._requestQueue.send(l),{updatedPolls:d,deletedPollIds:p,hasMore:h,nextToken:u}=i.as(r);return d.length>0&&this._dispatcher.dispatch(new e.PollChangeLogEventCommand({polls:d,source:o})),{updatedPolls:d,deletedPollIds:p,hasMore:h,token:u}}))}},exports.PollOptionRetrievalParamsDefault=h,exports.PollRetrievalParamsDefault=c,exports.PollUpdateEvent=class{constructor(e,t){this.pollId=0,this.messageId=0,this.pollId=t.poll.id,this.messageId=t.poll.message_id,this._iid=e,this._payload=t}},exports.PollVoteEvent=class{constructor(e){this.pollId=0,this.messageId=0,this.pollId=e.poll_id,this.messageId=e.message_id,this._payload=e}},exports.PollVoterListQuery=O,exports.validatePollCreateParams=p,exports.validatePollOptionRetrievalParams=u,exports.validatePollRetrievalParams=m; diff --git a/cjs/lib/__bundle-491c6c05.js b/cjs/lib/__bundle-491c6c05.js new file mode 100644 index 0000000..bd67037 --- /dev/null +++ b/cjs/lib/__bundle-491c6c05.js @@ -0,0 +1 @@ +"use strict";var t="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{},e="URLSearchParams"in t,r="Symbol"in t&&"iterator"in Symbol,o="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),n="FormData"in t,s="ArrayBuffer"in t;if(s)var i=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],a=ArrayBuffer.isView||function(t){return t&&i.indexOf(Object.prototype.toString.call(t))>-1};function h(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||""===t)throw new TypeError('Invalid character in header field name: "'+t+'"');return t.toLowerCase()}function u(t){return"string"!=typeof t&&(t=String(t)),t}function f(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return r&&(e[Symbol.iterator]=function(){return e}),e}function d(t){this.map={},t instanceof d?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){if(2!=t.length)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+t.length);this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function c(t){if(!t._noBody)return t.bodyUsed?Promise.reject(new TypeError("Already read")):void(t.bodyUsed=!0)}function y(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function l(t){var e=new FileReader,r=y(e);return e.readAsArrayBuffer(t),r}function p(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(t){var r;this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:o&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:n&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:e&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():s&&o&&((r=t)&&DataView.prototype.isPrototypeOf(r))?(this._bodyArrayBuffer=p(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s&&(ArrayBuffer.prototype.isPrototypeOf(t)||a(t))?this._bodyArrayBuffer=p(t):this._bodyText=t=Object.prototype.toString.call(t):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):e&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o&&(this.blob=function(){var t=c(this);if(t)return t;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 t=c(this);return t||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}if(o)return this.blob().then(l);throw new Error("could not read as ArrayBuffer")},this.text=function(){var t,e,r,o,n,s=c(this);if(s)return s;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=y(e),o=/charset=([A-Za-z0-9_-]+)/.exec(t.type),n=o?o[1]:"utf-8",e.readAsText(t,n),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),o=0;o-1?n:o),this.mode=r.mode||this.mode||null,this.signal=r.signal||this.signal||function(){if("AbortController"in t)return(new AbortController).signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&s)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(s),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==r.cache&&"no-cache"!==r.cache)){var i=/([?&])_=[^&]*/;if(i.test(this.url))this.url=this.url.replace(i,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function g(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),o=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(o),decodeURIComponent(n))}})),e}function v(t,e){if(!(this instanceof v))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===e.statusText?"":""+e.statusText,this.headers=new d(e.headers),this.url=e.url||"",this._initBody(t)}w.prototype.clone=function(){return new w(this,{body:this._bodyInit})},b.call(w.prototype),b.call(v.prototype),v.prototype.clone=function(){return new v(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},v.error=function(){var t=new v(null,{status:200,statusText:""});return t.status=0,t.type="error",t};var A=[301,302,303,307,308];v.redirect=function(t,e){if(-1===A.indexOf(e))throw new RangeError("Invalid status code");return new v(null,{status:e,headers:{location:t}})};var T=t.DOMException;try{new T}catch(t){(T=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack}).prototype=Object.create(Error.prototype),T.prototype.constructor=T}function _(e,r){return new Promise((function(n,i){var a=new w(e,r);if(a.signal&&a.signal.aborted)return i(new T("Aborted","AbortError"));var f=new XMLHttpRequest;function c(){f.abort()}if(f.onload=function(){var t=f.getAllResponseHeaders(),e=f.getResponseHeader("set-cookie");e&&(t=t.replace(e,e.replace(/\r?\n/g,", ")));var r,o,s={status:f.status,statusText:f.statusText,headers:(r=t||"",o=new d,r.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(t){return 0===t.indexOf("\n")?t.substr(1,t.length):t})).forEach((function(t){var e=t.split(":"),r=e.shift().trim();if(r){var n=e.join(":").trim();try{o.append(r,n)}catch(t){console.warn("Response "+t.message)}}})),o)};s.url="responseURL"in f?f.responseURL:s.headers.get("X-Request-URL");var i="response"in f?f.response:f.responseText;setTimeout((function(){n(new v(i,s))}),0)},f.onerror=function(){setTimeout((function(){i(new TypeError("Network request failed"))}),0)},f.ontimeout=function(){setTimeout((function(){i(new TypeError("Network request failed"))}),0)},f.onabort=function(){setTimeout((function(){i(new T("Aborted","AbortError"))}),0)},f.open(a.method,function(e){try{return""===e&&t.location.href?t.location.href:e}catch(t){return e}}(a.url),!0),"include"===a.credentials?f.withCredentials=!0:"omit"===a.credentials&&(f.withCredentials=!1),"responseType"in f&&(o?f.responseType="blob":s&&(f.responseType="arraybuffer")),r&&"object"==typeof r.headers&&!(r.headers instanceof d||t.Headers&&r.headers instanceof t.Headers)){var y=[];Object.getOwnPropertyNames(r.headers).forEach((function(t){y.push(h(t)),f.setRequestHeader(t,u(r.headers[t]))})),a.headers.forEach((function(t,e){-1===y.indexOf(e)&&f.setRequestHeader(e,t)}))}else a.headers.forEach((function(t,e){f.setRequestHeader(e,t)}));a.signal&&(a.signal.addEventListener("abort",c),f.onreadystatechange=function(){4===f.readyState&&a.signal.removeEventListener("abort",c)}),f.send(void 0===a._bodyInit?null:a._bodyInit)}))}_.polyfill=!0,t.fetch||(t.fetch=_,t.Headers=d,t.Request=w,t.Response=v); diff --git a/cjs/lib/__bundle-72519a03.js b/cjs/lib/__bundle-72519a03.js new file mode 100644 index 0000000..769e429 --- /dev/null +++ b/cjs/lib/__bundle-72519a03.js @@ -0,0 +1 @@ +"use strict";var e;e=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 r=0;rnew s.User(this._iid,e))):[],this.lastRepliedAt=null!==(a=t.last_replied_at)&&void 0!==a?a:0,this.updatedAt=null!==(n=t.updated_at)&&void 0!==n?n:0}static payloadify(e){return s.deundefined(s.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{reply_count:e.replyCount,most_replies:Array.isArray(e.mostRepliedUsers)?e.mostRepliedUsers.map((e=>s.User.payloadify(e))):[],last_replied_at:e.lastRepliedAt,updated_at:e.updatedAt})))}}exports.ReactionEventOperation=void 0,(e=exports.ReactionEventOperation||(exports.ReactionEventOperation={})).ADD="add",e.DELETE="delete";class n{constructor(e){var t;const i=e.key,a=null!==(t=[...e.user_ids])&&void 0!==t?t:[],n=e.updated_at;s.isTypeOf("string",i)&&i&&s.isArrayOf("string",a)&&a.length>0&&s.isTypeOf("number",n)&&(this.key=i,this.userIds=a,this.updatedAt=n);const r={};for(const e of this.userIds)r[e]=this.updatedAt;this._version=r}get isEmpty(){return 0===this.userIds.length}static payloadify(e){return s.deundefined(s.undefineNullProps({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}))}applyEvent(e){if(e.key===this.key&&this.updatedAt<=e.updatedAt){if(!this._version[e.userId]||this._version[e.userId]<=e.updatedAt){const s=this.userIds.indexOf(e.userId);switch(e.operation){case exports.ReactionEventOperation.ADD:s<0&&this.userIds.push(e.userId);break;case exports.ReactionEventOperation.DELETE:s>=0&&this.userIds.splice(s,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}}}class r{constructor(e){this.key=e.key,this.value=s.isArrayOf("string",e.value)?[...e.value]:[]}static payloadify(e){var t;return s.deundefined(s.undefineNullProps({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}))}}class l{constructor(e){this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,this.url=e.url,e.secure_url&&(this.secureUrl=e.secure_url),e.type&&(this.type=e.type),e.width&&(this.width=e.width),e.height&&(this.height=e.height),e.alt&&(this.alt=e.alt)}static payloadify(e){var t,i;return s.deundefined(s.undefineNullProps({url:e.url,secure_url:e.secureUrl,type:e.type,width:null!==(t=e.width)&&void 0!==t?t:0,height:null!==(i=e.height)&&void 0!==i?i:0,alt:e.alt}))}}class d{constructor(e){this.title=null,this.url=null,this.description=null,this.defaultImage=null,e["og:title"]&&(this.title=e["og:title"]),e["og:url"]&&(this.url=e["og:url"]),e["og:description"]&&(this.description=e["og:description"]),e["og:image"]&&(this.defaultImage=new l(e["og:image"]))}static payloadify(e){return s.deundefined(s.undefineNullProps({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?l.payloadify(e.defaultImage):null}))}}class o{constructor(e){var s,t;this.volume=0,this.name=null!==(s=e.name)&&void 0!==s?s:"default",this.volume=null!==(t=e.volume)&&void 0!==t?t:1}serialize(){return{name:this.name,volume:this.volume}}static payloadify(e){return s.deundefined(s.undefineNullProps({name:e.name,volume:e.volume}))}}class u extends s.User{constructor(e,t){var i;super(e,t),this.isBlockedByMe=!1,this.role=s.isEnumOf(s.Role,t.role)?t.role:s.Role.NONE,this.isBlockedByMe=null!==(i=t.is_blocked_by_me)&&void 0!==i&&i}static payloadify(e){return s.deundefined(s.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})))}}var h,p;exports.ScheduledStatus=void 0,(h=exports.ScheduledStatus||(exports.ScheduledStatus={})).PENDING="pending",h.SENT="sent",h.FAILED="failed",h.CANCELED="canceled",exports.InternalScheduledStatus=void 0,(p=exports.InternalScheduledStatus||(exports.InternalScheduledStatus={})).PENDING="pending",p.IN_QUEUE="in_queue",p.SENT="sent",p.FAILED="failed",p.CANCELED="canceled",p.REMOVED="removed";const c=e=>{switch(e){case s.MessageType.BASE:return"";case s.MessageType.USER:return"MESG";case s.MessageType.FILE:return"FILE";case s.MessageType.ADMIN:return"ADMM"}};class m extends s.InstancedObject{constructor(e,t){var i,l,u,h,p,c,m,g,y,_,f,v,I,T,M,S;super(e),this.channelType=s.ChannelType.BASE,this.parentMessage=null,this.silent=!1,this.isOperatorMessage=!1,this.messageType=s.MessageType.BASE,this.mentionType=null,this.threadInfo=null,this.reactions=[],this.metaArrays=[],this.appleCriticalAlertOptions=null,this.createdAt=0,this.updatedAt=0,this.scheduledInfo=null,this.extendedMessage={},this._isContinuousMessages=!1,this._scheduledStatus=null,this.messageId=null!==(l=null!==(i=t.msg_id)&&void 0!==i?i:t.message_id)&&void 0!==l?l:0,this.channelUrl=t.channel_url,this.channelType=s.isEnumOf(s.ChannelType,t.channel_type)?t.channel_type:s.ChannelType.GROUP,t.channel&&(t.channel.channel_url&&(this.channelUrl=t.channel.channel_url),t.channel.channel_type&&(this.channelType=t.channel.channel_type)),this.parentMessageId=null!==(u="string"==typeof t.parent_message_id?parseInt(t.parent_message_id):t.parent_message_id)&&void 0!==u?u:0,this.data=null!==(h=t.data)&&void 0!==h?h:"",this.customType=null!==(p=t.custom_type)&&void 0!==p?p:"",this.mentionType=s.isEnumOf(s.MentionType,t.mention_type)?t.mention_type:null,this.mentionedUsers=t.mentioned_users?t.mentioned_users.map((e=>new s.User(this._iid,e))):null,this.mentionedUserIds=null!==(c=t.mentioned_user_ids)&&void 0!==c?c:null,this.mentionedUsers&&!this.mentionedUserIds&&(this.mentionedUserIds=this.mentionedUsers.map((e=>e.userId))),this.mentionedMessageTemplate=null!==(m=t.mentioned_message_template)&&void 0!==m?m:"",this.threadInfo=t.thread_info?new a(this._iid,t.thread_info):null,this.reactions=t.reactions?t.reactions.map((e=>new n(e))):[];const O=null!==(g=t.metaarray)&&void 0!==g?g:{},A=null!==(y=t.metaarray_key_order)&&void 0!==y?y:Object.keys(O).sort(((e,s)=>e.localeCompare(s)));this.metaArrays=[];for(let e=0;enew r(e)))),this.ogMetaData=t.og_tag?new d(t.og_tag):null,this.silent=null!==(_=t.silent)&&void 0!==_&&_,this.isOperatorMessage=null!==(f=t.is_op_msg)&&void 0!==f&&f,this.appleCriticalAlertOptions=t.apple_critical_alert_options?new o(t.apple_critical_alert_options):null,this.createdAt=null!==(I=null!==(v=t.created_at)&&void 0!==v?v:t.ts)&&void 0!==I?I:0,this.updatedAt=null!==(T=t.updated_at)&&void 0!==T?T:0,"number"==typeof t.scheduled_message_id&&"number"==typeof t.scheduled_at&&t.scheduled_status&&(this.scheduledInfo={scheduledMessageId:t.scheduled_message_id,scheduledAt:t.scheduled_at},this._scheduledStatus=t.scheduled_status),this.extendedMessage=null!==(M=t.extended_message)&&void 0!==M?M:{},this._isContinuousMessages=null!==(S=t.is_continuous_messages)&&void 0!==S&&S}static payloadify(e){var t,i,l,u;return s.deundefined(s.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{channel_url:e.channelUrl,channel_type:e.channelType,message_id:e.messageId,type:c(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((e=>s.User.payloadify(e))),mentioned_message_template:e.mentionedMessageTemplate,thread_info:e.threadInfo?a.payloadify(e.threadInfo):null,reactions:e.reactions.map((e=>n.payloadify(e))),sorted_metaarray:null===(i=e.metaArrays)||void 0===i?void 0:i.map((e=>r.payloadify(e))),og_tag:e.ogMetaData?d.payloadify(e.ogMetaData):null,silent:e.silent,is_op_msg:e.isOperatorMessage,apple_critical_alert_options:e.appleCriticalAlertOptions?o.payloadify(e.appleCriticalAlertOptions):null,created_at:e.createdAt,updated_at:e.updatedAt,scheduled_message_id:null===(l=e.scheduledInfo)||void 0===l?void 0:l.scheduledMessageId,scheduled_at:null===(u=e.scheduledInfo)||void 0===u?void 0:u.scheduledAt,scheduled_status:e._scheduledStatus,extended_message:e.extendedMessage})))}static _getParentMessageInfoPayload(e){return s.deundefined(s.undefineNullProps({type:e.messageType,ts:e.createdAt,user:e.sender?u.payloadify(e.sender):null,message:e.message,file:{url:e.plainUrl,name:e.name,type:e.type,require_auth:e.requireAuth}}))}isIdentical(e){return this.messageId===e.messageId}isEqual(e){return s.deepEqual(this,e)}isUserMessage(){return this.messageType===s.MessageType.USER}isFileMessage(){return this.messageType===s.MessageType.FILE&&!Object.prototype.hasOwnProperty.call(this,"fileInfoList")}isMultipleFilesMessage(){return this.messageType===s.MessageType.FILE&&Object.prototype.hasOwnProperty.call(this,"fileInfoList")}isAdminMessage(){return this.messageType===s.MessageType.ADMIN}serialize(){return s.serialize(this)}getMetaArraysByKeys(e){return this.metaArrays.filter((s=>e.includes(s.key)))}applyThreadInfoUpdateEvent(e){return this.messageId===e.targetMessageId&&(this.threadInfo=e.threadInfo),!1}applyReactionEvent(e){if(this.messageId===e.messageId){let s=!1;for(let t=0;t=s)return this.parentMessage=e,!0}return!1}}class g extends m{constructor(e,t){var i,a,n,r;if(super(e,t),this.reqId="",this.replyToChannel=!1,this.errorCode=0,this.sender=t.user?new u(this._iid,t.user):t.sender_id,this.reqId=null!==(a=null!==(i=t.req_id)&&void 0!==i?i:t.request_id)&&void 0!==a?a:"",this.replyToChannel=null!==(n=t.is_reply_to_channel)&&void 0!==n&&n,t.request_state&&s.isEnumOf(s.SendingStatus,t.request_state)&&(this.sendingStatus=t.request_state),!this.sendingStatus)if(this.messageId>0)this.sendingStatus=s.SendingStatus.SUCCEEDED;else if(this.scheduledInfo)switch(t.scheduled_status&&(this._scheduledStatus=t.scheduled_status),t.scheduled_status){case exports.InternalScheduledStatus.SENT:case exports.InternalScheduledStatus.IN_QUEUE:this.sendingStatus=s.SendingStatus.SUCCEEDED;break;case exports.InternalScheduledStatus.PENDING:this.sendingStatus=s.SendingStatus.SCHEDULED;break;case exports.InternalScheduledStatus.FAILED:case exports.InternalScheduledStatus.REMOVED:this.sendingStatus=s.SendingStatus.FAILED;break;case exports.InternalScheduledStatus.CANCELED:this.sendingStatus=s.SendingStatus.CANCELED}else this.sendingStatus=s.SendingStatus.PENDING;this.errorCode=null!==(r=t.error_code)&&void 0!==r?r:0}static payloadify(e){return s.deundefined(s.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{user:u.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode})))}get isResendable(){return this.sendingStatus===s.SendingStatus.FAILED&&s.isResendableError(this.errorCode)}isIdentical(e){return this.messageId>0&&e.messageId>0?this.messageId===e.messageId:this.reqId===e.reqId}}class y{constructor(e){var s,t;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!==(s=e.real_width)&&void 0!==s?s:e.width,this.realHeight=null!==(t=e.real_height)&&void 0!==t?t:e.height}static payloadify(e){return s.deundefined(s.undefineNullProps({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}))}get plainUrl(){return this.url.split("?auth=")[0]}}const _={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:s.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},f=e=>s.isTypeOf("number",e.prevResultSize)&&s.isTypeOf("number",e.nextResultSize)&&s.isTypeOf("boolean",e.isInclusive)&&s.isTypeOf("boolean",e.reverse)&&s.isTypeOf("string",e.messageTypeFilter)&&s.isEnumOf(s.MessageTypeFilter,e.messageTypeFilter)&&s.isArrayOf("string",e.customTypesFilter,!0)&&s.isArrayOf("string",e.senderUserIdsFilter,!0)&&s.isTypeOf("boolean",e.includeMetaArray)&&s.isTypeOf("boolean",e.includeReactions)&&s.isTypeOf("boolean",e.includeParentMessageInfo);class v extends m{constructor(e,t){var i,a,n,r;if(super(e,t),this.translations={},this.message=null!==(i=t.message)&&void 0!==i?i:"",this.messageType=s.MessageType.ADMIN,this.translations=null!==(a=t.translations)&&void 0!==a?a:{},t.parent_message_info){const i=t.parent_message_info;this.parentMessage=O(e,s.deundefined(s.undefineNullProps(Object.assign(Object.assign({},i),{message_id:this.parentMessageId,channel_url:this.channelUrl,channel_type:this.channelType,file:i.file,url:null===(n=i.file)||void 0===n?void 0:n.url,require_auth:null===(r=i.file)||void 0===r?void 0:r.require_auth}))))}}static payloadify(e){return s.deundefined(s.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{message:e.message,translations:e.translations,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null})))}getThreadedMessagesByTimestamp(e,t){return s.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},_),t);s.unless(this.messageId>0&&s.isTypeOf("number",e)&&f(i)).throw(s.SendbirdError.invalidParameters);const a=B.of(this._iid);return yield a.getThreadedMessagesByTimestamp(this,e,i)}))}}class I{constructor(e){var t,i;this.detail={},this.type=null!==(t=e.type)&&void 0!==t?t:"",this.vendor=null!==(i=e.vendor)&&void 0!==i?i:"",e.detail&&s.isTypeOf("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}static payloadify(e){return s.deundefined(s.undefineNullProps({type:e.type,vendor:e.vendor,detail:e.detail}))}}class T extends g{constructor(e,t){var i,a,n,r,l;if(super(e,t),this.message="",this.messageParams=null,this.translations={},this.translationTargetLanguages=[],this.messageSurvivalSeconds=-1,this.plugins=[],this._poll=null,this.message=t.message,this.messageType=s.MessageType.USER,this.translations=null!==(i=t.translations)&&void 0!==i?i:{},this.translationTargetLanguages=null!==(a=t.target_langs)&&void 0!==a?a:[],0===Object.keys(this.translations).length&&this.translationTargetLanguages.length>0)for(const e of this.translationTargetLanguages)this.translations[e]="";if(this.messageSurvivalSeconds=null!==(n=t.message_survival_seconds)&&void 0!==n?n:-1,this.plugins=t.plugins?t.plugins.map((e=>new I(e))):[],this._poll=t.poll?new s.Poll(this._iid,t.poll):null,t.parent_message_info){const i=t.parent_message_info;this.parentMessage=O(e,s.deundefined(s.undefineNullProps(Object.assign(Object.assign({},i),{created_at:i.ts,message_id:this.parentMessageId,channel_url:this.channelUrl,channel_type:this.channelType,file:i.file,url:null===(r=i.file)||void 0===r?void 0:r.url,require_auth:null===(l=i.file)||void 0===l?void 0:l.require_auth}))))}}static payloadify(e){return s.deundefined(s.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{message:e.message,translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((e=>I.payloadify(e))),poll:e._poll?s.Poll.payloadify(e._poll):null,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null})))}getThreadedMessagesByTimestamp(e,t){return s.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},_),t);s.unless(this.messageId>0&&s.isTypeOf("number",e)&&f(i)).throw(s.SendbirdError.invalidParameters);const a=B.of(this._iid);return yield a.getThreadedMessagesByTimestamp(this,e,i)}))}applyPoll(e){return!(this._poll&&this._poll.id===e.id&&this._poll.updatedAt>e.updatedAt)&&(this._poll=e,!0)}get poll(){return this._poll}}class M extends s.InstancedObject{constructor(e,t){var i,a,n,r,l;super(e),this.plainUrl="",this.fileName=null,this.mimeType=null,this.fileSize=0,this.thumbnails=[],this._requireAuth=!1,this.plainUrl=null!==(i=t.url)&&void 0!==i?i:"",this.fileName=null!==(a=t.file_name)&&void 0!==a?a:null,this.mimeType=null!==(n=t.file_type)&&void 0!==n?n:null,this.fileSize=null!==(r=t.file_size)&&void 0!==r?r:0,this._requireAuth=null!==(l=t.require_auth)&&void 0!==l&&l;const{sessionManager:d}=s.Vault.of(this._iid);this.thumbnails=t.thumbnails?t.thumbnails.map((e=>new y(Object.assign(Object.assign({},e),{url:`${e.url.split("?auth=")[0]}${this._requireAuth?`?auth=${d.ekey}`:""}`})))):[]}static payloadify(e){var t;return s.deundefined(s.undefineNullProps({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((e=>({url:e.url,width:e.width,height:e.height,real_width:e.realWidth,real_height:e.realHeight}))),require_auth:e._requireAuth}))}get url(){const{sessionManager:e}=s.Vault.of(this._iid);return this._requireAuth?`${this.plainUrl}?auth=${e.ekey}`:this.plainUrl}}class S extends g{constructor(e,t){var i,a,n,r,l;if(super(e,t),this.messageParams=null,this.fileInfoList=[],this.messageSurvivalSeconds=-1,this.messageType=s.MessageType.FILE,this.fileInfoList=null!==(a=null===(i=t.files)||void 0===i?void 0:i.map((s=>new M(e,s))))&&void 0!==a?a:[],this.messageSurvivalSeconds=null!==(n=t.message_survival_seconds)&&void 0!==n?n:-1,t.parent_message_info){const i=t.parent_message_info;this.parentMessage=O(e,s.deundefined(s.undefineNullProps(Object.assign(Object.assign({},i),{created_at:i.ts,message_id:this.parentMessageId,channel_url:this.channelUrl,channel_type:this.channelType,file:i.file,url:null===(r=i.file)||void 0===r?void 0:r.url,require_auth:null===(l=i.file)||void 0===l?void 0:l.require_auth}))))}}getThreadedMessagesByTimestamp(e,t){return s.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},_),t);s.unless(this.messageId>0&&s.isTypeOf("number",e)&&f(i)).throw(s.SendbirdError.invalidParameters);const a=B.of(this._iid);return yield a.getThreadedMessagesByTimestamp(this,e,i)}))}static payloadify(e){return s.deundefined(s.undefineNullProps(Object.assign(Object.assign({},super.payloadify(e)),{files:e.fileInfoList&&e.fileInfoList&&Array.isArray(e.fileInfoList)?e.fileInfoList.map((e=>M.payloadify(e))):null,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null})))}static _isMultipleFilesMessagePayload(e){const s=e.files;return Array.isArray(s)&&s.length>=2}static _isMultipleFilesMessageSerializedData(e){const s=e.fileInfoList;return Array.isArray(s)}}const O=(e,t)=>{switch(t.type){case"MESG":return new T(e,t);case"FILE":return S._isMultipleFilesMessagePayload(t)?new S(e,t):new A(e,t);case"ADMM":case"BRDM":return new v(e,t)}throw s.SendbirdError.unknown};class A extends g{constructor(e,t){var i,a,n,r,l,d,o,u,h,p,c,m,g,_;super(e,t),this.messageParams=null,this.plainUrl="",this.requireAuth=!1,this.thumbnails=[],this.messageSurvivalSeconds=-1,this.messageType=s.MessageType.FILE;const f=t.file;this.plainUrl=(null!==(a=null!==(i=null==f?void 0:f.url)&&void 0!==i?i:t.url)&&void 0!==a?a:"").split("?auth=")[0],this.name=null!==(r=null!==(n=null==f?void 0:f.name)&&void 0!==n?n:t.name)&&void 0!==r?r:"File",this.size=null!==(d=null!==(l=null==f?void 0:f.size)&&void 0!==l?l:t.size)&&void 0!==d?d:0,this.data=null!==(u=null!==(o=null==f?void 0:f.data)&&void 0!==o?o:t.custom)&&void 0!==u?u:"",this.type=f?null!==(h=f.type)&&void 0!==h?h:"":null!==(p=t.type)&&void 0!==p?p:"";const{sessionManager:v}=s.Vault.of(this._iid);if(this.requireAuth=null!==(c=t.require_auth)&&void 0!==c&&c,this.thumbnails=t.thumbnails?t.thumbnails.map((e=>new y(Object.assign(Object.assign({},e),{url:`${e.url.split("?auth=")[0]}${this.requireAuth?`?auth=${v.ekey}`:""}`})))):[],this.messageSurvivalSeconds=null!==(m=t.message_survival_seconds)&&void 0!==m?m:-1,t.parent_message_info){const i=t.parent_message_info;this.parentMessage=O(e,s.deundefined(s.undefineNullProps(Object.assign(Object.assign({},i),{created_at:i.ts,message_id:this.parentMessageId,channel_url:this.channelUrl,channel_type:this.channelType,file:i.file,url:null===(g=i.file)||void 0===g?void 0:g.url,require_auth:null===(_=i.file)||void 0===_?void 0:_.require_auth}))))}}static payloadify(e){var t;return s.deundefined(s.undefineNullProps(Object.assign(Object.assign({},super.payloadify(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((e=>({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:e.parentMessage?super._getParentMessageInfoPayload(e.parentMessage):null})))}get url(){const{sessionManager:e}=s.Vault.of(this._iid);return this.requireAuth?`${this.plainUrl}?auth=${e.ekey}`:this.plainUrl}getThreadedMessagesByTimestamp(e,t){return s.__awaiter(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},_),t);s.unless(this.messageId>0&&s.isTypeOf("number",e)&&f(i)).throw(s.SendbirdError.invalidParameters);const a=B.of(this._iid);return yield a.getThreadedMessagesByTimestamp(this,e,i)}))}}class E extends s.WebSocketRequestCommand{constructor(e){var t,i,a;let n=[];e.mentionType===s.MentionType.USERS&&(e.mentionedUserIds?n=e.mentionedUserIds:e.mentionedUsers&&(n=e.mentionedUsers.map((e=>e.userId)))),super({code:"FILE",ackRequired:!0,payload:s.deundefined(s.undefineNullProps({channel_url:e.channelUrl,files:e.files?C(e.files):null,url:e.url,name:null!==(t=e.fileName)&&void 0!==t?t:"",type:null!==(i=e.mimeType)&&void 0!==i?i:"",size:null!==(a=e.fileSize)&&void 0!==a?a: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:n,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==s.PushNotificationDeliveryOption.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions?o.payloadify(e.appleCriticalAlertOptions):null,silent:e.silent,reply_to_channel:e.isReplyToChannel,parent_message_id:e.parentMessageId?e.parentMessageId:null,req_id:e.reqId,pin_message:e.isPinnedMessage}))})}}class b extends s.APIRequestCommand{constructor(e){var t,i;super();let a=[];e.mentionType===s.MentionType.USERS&&(e.mentionedUserIds?a=e.mentionedUserIds:e.mentionedUsers&&(a=e.mentionedUsers.map((e=>e.userId)))),this.method=s.APIRequestMethod.POST,this.path=`${s.getChannelApiPathByType(e.channelType)}/${encodeURIComponent(e.channelUrl)}/messages`,this.params=s.deundefined(s.undefineNullProps({message_type:s.MessageType.FILE,user_id:e.userId,files:e.files?C(e.files):null,url:e.fileUrl,mention_type:e.mentionType,mentioned_user_ids:a,file_name:e.fileName,file_size:e.fileSize,file_type:e.mimeType,data:e.data,custom_type:e.customType,thumbnails:null===(t=e.thumbnailSizes)||void 0===t?void 0:t.map((e=>y.payloadify(e))),require_auth:e.requireAuth,sorted_metaarray:null===(i=e.metaArrays)||void 0===i?void 0:i.map((e=>r.payloadify(e))),push_option:e.pushNotificationDeliveryOption,parent_message_id:e.parentMessageId?e.parentMessageId:null,apple_critical_alert_options:e.appleCriticalAlertOptions?o.payloadify(e.appleCriticalAlertOptions):null,reply_to_channel:e.isReplyToChannel,req_id:e.reqId,pin_message:e.isPinnedMessage}))}}class U extends s.WebSocketEventCommand{constructor(e,t,i){var a,n,r,l;super(e,"FILE",i),this.message=i.files&&i.files.length>=2?new S(e,i):new A(e,i);const{sdkState:d}=s.Vault.of(e);this.isMentioned=s.checkIfMentioned(this.message.mentionType,null!==(r=null!==(a=this.message.mentionedUserIds)&&void 0!==a?a:null===(n=this.message.mentionedUsers)||void 0===n?void 0:n.map((e=>e.userId)))&&void 0!==r?r:[],d.userId),this.forceUpdateLastMessage=null!==(l=i.force_update_last_message)&&void 0!==l&&l}}class P extends s.APIResponseCommand{constructor(e,t){var i,a,n,r;super(e,t),this.message=t.files&&t.files.length>=2?new S(e,t):new A(e,t);const{sdkState:l}=s.Vault.of(e);this.isMentioned=s.checkIfMentioned(this.message.mentionType,null!==(n=null!==(i=this.message.mentionedUserIds)&&void 0!==i?i:null===(a=this.message.mentionedUsers)||void 0===a?void 0:a.map((e=>e.userId)))&&void 0!==n?n:[],l.userId),this.forceUpdateLastMessage=null!==(r=t.force_update_last_message)&&void 0!==r&&r}}function C(e){return e.map((e=>{var t,i;return s.deundefined(s.undefineNullProps({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((e=>y.payloadify(e))),require_auth:null===(i=e._uploadedMetaData)||void 0===i?void 0:i.requireAuth}))}))}var x;!function(e){e[e.PENDING=0]="PENDING",e[e.UPLOADING=1]="UPLOADING",e[e.UPLOADED=2]="UPLOADED",e[e.SENDING=3]="SENDING",e[e.FAILED=4]="FAILED"}(x||(x={}));class F{constructor(e,{sdkState:t,dispatcher:i,requestQueue:a,onlineDetector:n,cacheContext:r}){this._queueMap=new Map,this._iid=e,this._sdkState=t,this._requestQueue=a,this._cacheContext=r,this._dispatcher=i,this._dispatcher.on((e=>{e instanceof s.ConnectionStateChangeCommand&&(this._connectionState=e.stateType)})),this._onlineDetector=n}get _shouldSendThroughWebSocket(){return this._connectionState===s.ConnectionStateType.CONNECTED||this._connectionState===s.ConnectionStateType.CONNECTING||this._connectionState===s.ConnectionStateType.RECONNECTING}_sendFileMessage(e,t){return s.__awaiter(this,void 0,void 0,(function*(){const s=this._createSendFileMessageRequestParams(e,t);if(this._shouldSendThroughWebSocket){const e=new E(s),t=yield this._requestQueue.send(e),{message:i}=t.as(U);return i}{const e=new b(Object.assign(Object.assign({},s),{userId:this._sdkState.userId})),t=yield this._requestQueue.send(e),{message:i}=t.as(P);return i}}))}_createSendFileMessageRequestParams(e,s){const t=Object.assign(Object.assign({},s.params),{channelUrl:e.url,channelType:e.channelType,reqId:s.requestId,url:""});if(s.multipleFileUploadInfo){const e=s.params;t.files=e.fileInfoList}else{const e=s.params;t.url=e.fileUrl,t.requireAuth=e.requireAuth}return t}_resolveMessageQueue(e){var t;return s.__awaiter(this,void 0,void 0,(function*(){const i=this._queueMap.get(e.url);if(i)if(i.isResolving)i.isResolveRequestPending=!0;else{i.isResolving=!0;const a=[];let n=!0;for(const r of i.messageQueue)switch(r.state){case x.PENDING:case x.UPLOADING:n=!1,a.push(r);break;case x.UPLOADED:if(n)try{r.state=x.SENDING;const t=yield this._sendFileMessage(e,r);r.deferred.resolve(t),yield s.sleep(100)}catch(e){r.deferred.reject(e)}else a.push(r);break;case x.FAILED:{const e=null!==(t=r.error)&&void 0!==t?t:s.SendbirdError.unknown;r.deferred.reject(e.code===s.SendbirdErrorCode.REQUEST_CANCELED?s.SendbirdError.fileUploadCanceled:e);break}}const r=i.isResolveRequestPending;i.messageQueue=a,i.isResolving=!1,i.isResolveRequestPending=!1,r&&(yield this._resolveMessageQueue(e))}}))}_uploadNextPendingItem(e){var t;return s.__awaiter(this,void 0,void 0,(function*(){const i=this._queueMap.get(e.url);if(i){const a=i.messageQueue.find((e=>e.state===x.PENDING));if(a){if(a.multipleFileUploadInfo){const{uploadIndex:n,uploadCount:r,requestHandler:l}=a.multipleFileUploadInfo,d=a.params.fileInfoList[n];s.isFile(d.file)&&!(null===(t=d._uploadedMetaData)||void 0===t?void 0:t.isUploaded)?yield this._tryUploadNextItemAndUpdateItemState(e,i,a):a.state=ne.requestId===s.requestId));t>=0&&e.uploadQueue.splice(t,1)}_uploadNextFileForSingleFileItemAndUpdateParams(e,a,n){var r,l,d;return s.__awaiter(this,void 0,void 0,(function*(){const s=new t({file:n.file,channelUrl:e.url,thumbnailSizes:n.thumbnailSizes,requestId:a.requestId}),o=yield this._requestQueue.send(s),{url:u,fileSize:h=n.fileSize,thumbnailSizes:p=n.thumbnailSizes,requireAuth:c=!1}=o.as(i);n.fileName=null!==(r=n.fileName)&&void 0!==r?r:n.file.name,n.mimeType=null!==(l=n.mimeType)&&void 0!==l?l:n.file.type,n.fileSize=null!==(d=n.fileSize)&&void 0!==d?d:n.file.size,n.fileUrl=u,n.fileSize=h,n.thumbnailSizes=p,n.requireAuth=c}))}_uploadNextFileForMultipleFilesItemAndUpdateParams(e,a,n){var r,l,d;return s.__awaiter(this,void 0,void 0,(function*(){const{uploadIndex:s}=a.multipleFileUploadInfo,o=n.fileInfoList[s],u=new t({file:o.file,channelUrl:e.url,thumbnailSizes:o.thumbnailSizes,requestId:a.requestId}),h=yield this._requestQueue.send(u),{url:p,fileSize:c=o.fileSize,thumbnailSizes:m=o.thumbnailSizes,requireAuth:g=!1}=h.as(i);o.fileName=null!==(r=o.fileName)&&void 0!==r?r:o.file.name,o.mimeType=null!==(l=o.mimeType)&&void 0!==l?l:o.file.type,o.fileSize=null!==(d=o.fileSize)&&void 0!==d?d:o.file.size,o.file=void 0,o.fileUrl=p,o.fileSize=c,o.thumbnailSizes=m,o._uploadedMetaData=Object.assign(Object.assign({},o._uploadedMetaData),{requireAuth:g,isUploaded:!0})}))}request(e,t,i,a){return s.__awaiter(this,void 0,void 0,(function*(){if(!this._queueMap.has(e.url)){const s={messageQueue:[],uploadQueue:[],isResolving:!1,isResolveRequestPending:!1};this._queueMap.set(e.url,s)}const n=this._queueMap.get(e.url),r=new s.Deferred,l={requestId:t,params:i,state:x.PENDING,deferred:r};if(function(e){return"fileInfoList"in e}(i)){const e={uploadIndex:0,uploadCount:i.fileInfoList.length,requestHandler:a};l.multipleFileUploadInfo=e}return n.messageQueue.push(l),this._uploadNextPendingItem(e),r.promise}))}cancel(e,t){const i=this._queueMap.get(e.url);if(i){const a=t?[i.messageQueue.find((e=>e.requestId===t))]:[...i.messageQueue];for(const t of a)if(t)switch(t.state){case x.PENDING:t.state=x.FAILED,t.error=s.SendbirdError.requestCanceled,this._resolveMessageQueue(e);break;case x.UPLOADING:this._requestQueue.cancel(t.requestId)}}}}const N={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:s.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:s.ReplyType.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},R={replyType:s.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1};class q extends s.APIRequestCommand{constructor({channelType:e,channelUrl:t,messageId:i,includeMetaArray:a,includeReactions:n,includeThreadInfo:r,includeParentMessageInfo:l}){super(),this.method=s.APIRequestMethod.GET,this.path=`${s.getChannelApiPathByType(e)}/${encodeURIComponent(t)}/messages/${encodeURIComponent(i)}`,this.params={is_sdk:!0,with_sorted_meta_array:a,include_reactions:n,include_thread_info:r,include_parent_message_info:l,include_poll_details:!0}}}class w extends s.APIResponseCommand{constructor(e,s){super(e,s),this.message=s?O(e,Object.assign({},s)):null}}class D extends s.APIRequestCommand{constructor({channelType:e,channelUrl:t,timestamp:i,token:a,prevResultSize:n,nextResultSize:r,isInclusive:l,reverse:d,messageTypeFilter:o,customTypesFilter:u,senderUserIdsFilter:h,replyType:p,includeMetaArray:c,includeReactions:m,parentMessageId:g,includeThreadInfo:y,includeParentMessageInfo:_,showSubchannelMessagesOnly:f,checkingContinuousMessages:v}){super(),this.method=s.APIRequestMethod.GET,this.path=`${s.getChannelApiPathByType(e)}/${encodeURIComponent(t)}/messages`,this.params=s.deundefined(s.undefineNullProps({is_sdk:!0,prev_limit:n,next_limit:r,include:l,reverse:d,message_ts:i,message_id:a,message_type:null!=o?o:null,custom_types:u,sender_ids:h,include_reply_type:p,with_sorted_meta_array:c,include_reactions:m,parent_message_id:g,include_thread_info:y,include_parent_message_info:_,show_subchannel_message_only:f,include_poll_details:!0,checking_continuous_messages:v}))}}class L extends s.APIResponseCommand{constructor(e,s){super(e,s),this.messages=s.messages.map((s=>O(e,s)))}}class k extends s.APIRequestCommand{constructor({channelType:e,channelUrl:t,timestamp:i,token:a,replyType:n,includeMetaArray:r,includeReactions:l,includeThreadInfo:d,includeParentMessageInfo:o}){super(),this.method=s.APIRequestMethod.GET,this.path=`${s.getChannelApiPathByType(e)}/${encodeURIComponent(t)}/messages/changelogs`,this.params={change_ts:i,token:a,with_sorted_meta_array:r,include_reactions:l,include_thread_info:d,include_reply_type:n,include_parent_message_info:o,include_poll_details:!0}}}class z extends s.APIResponseCommand{constructor(e,s){super(e,s),this.updatedMessages=s.updated.map((s=>O(e,s))),this.deletedMessagesInfo=s.deleted.map((e=>({messageId:e.message_id,deletedAt:e.deleted_at}))),this.hasMore=s.has_more,this.nextToken=s.next}}class j extends s.APIRequestCommand{constructor({channelUrl:e,scheduledMessageId:t}){super(),this.method=s.APIRequestMethod.GET,this.path=`${s.API_PATH_GROUP_CHANNELS}/${encodeURIComponent(e)}/scheduled_messages/${encodeURIComponent(t)}`,this.params={}}}class Q extends s.APIResponseCommand{constructor(e,s){super(e,s),this.message=s?O(e,Object.assign({},s)):null}}const G={};class B{constructor(e,{sdkState:s,dispatcher:t,requestQueue:i,onlineDetector:a,cacheContext:n}){this._iid=e,this._sdkState=s,this._requestQueue=i,this._dispatcher=t,this._cacheContext=n,this.fileMessageQueue=new F(e,{sdkState:s,dispatcher:t,requestQueue:i,onlineDetector:a,cacheContext:n}),G[e]=this}static of(e){return G[e]}buildMessageFromSerializedData(e){const t=s.deserialize(e);switch(t.messageType){case s.MessageType.USER:return new T(this._iid,T.payloadify(t));case s.MessageType.FILE:return S._isMultipleFilesMessageSerializedData(t)?new S(this._iid,S.payloadify(t)):new A(this._iid,A.payloadify(t));case s.MessageType.ADMIN:return new v(this._iid,v.payloadify(t))}throw s.SendbirdError.invalidParameters}buildUserMessageCreateParamsFromSerializedData(e,t){return s.deundefined(s.undefineNullProps({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}))}buildFileMessageCreateParamsFromSerializedData(e,t){var i;return s.deundefined(s.undefineNullProps({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===(i=t.thumbnails)||void 0===i?void 0:i.map((e=>({maxWidth:e.width,maxHeight:e.height}))),fileType:e.fileType,requireAuth:t.requireAuth}))}buildMultipleFilesMessageCreateParamsFromSerializedData(e,t){return s.deundefined({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})}buildScheduledUserMessageCreateParamsFromSerializedData(e,s){return Object.assign(Object.assign({},this.buildUserMessageCreateParamsFromSerializedData(e,s)),{scheduledAt:e.scheduledAt})}buildScheduledFileMessageCreateParamsFromSerializedData(e,s){return Object.assign(Object.assign({},this.buildFileMessageCreateParamsFromSerializedData(e,s)),{scheduledAt:e.scheduledAt})}buildSenderFromSerializedData(e){const t=s.deserialize(e);return new u(this._iid,u.payloadify(t))}getMessage(e){return s.__awaiter(this,void 0,void 0,(function*(){const s=new q(e),t=yield this._requestQueue.send(s),{message:i}=t.as(w);return i}))}getScheduledMessage(e){return s.__awaiter(this,void 0,void 0,(function*(){const s=new j(e),t=yield this._requestQueue.send(s),{message:i}=t.as(Q);return i}))}getMessagesByMessageId(e,t,i,a,n=s.MessageEventSource.REQUEST_MESSAGE){return s.__awaiter(this,void 0,void 0,(function*(){const r=new D(Object.assign(Object.assign({channelType:t,channelUrl:e,token:String(i)},N),a)),l=yield this._requestQueue.send(r),{messages:d}=l.as(L);return this._dispatcher.dispatch(new s.MessageUpdateEventCommand({messages:d,source:n})),d}))}getMessagesByTimestamp(e,t,i,a,n=s.MessageEventSource.REQUEST_MESSAGE){return s.__awaiter(this,void 0,void 0,(function*(){const r=new D(Object.assign(Object.assign({channelType:t,channelUrl:e,timestamp:i},N),a)),l=yield this._requestQueue.send(r),{messages:d}=l.as(L);return this._dispatcher.dispatch(new s.MessageUpdateEventCommand({messages:d,source:n})),d}))}_getMessagesByTimestampForCollection(e,t,i,a,n=s.MessageEventSource.REQUEST_MESSAGE,r){return s.__awaiter(this,void 0,void 0,(function*(){const l=new D(Object.assign(Object.assign(Object.assign({channelType:t,channelUrl:e,timestamp:i},N),a),{checkingContinuousMessages:r})),d=yield this._requestQueue.send(l),o=d.payload,{messages:u}=d.as(L);return this._dispatcher.dispatch(new s.MessageUpdateEventCommand({messages:u,source:n})),{messages:u,isContinuousMessages:o}}))}getThreadedMessagesByTimestamp(e,t,i,a=s.MessageEventSource.REQUEST_THREADED_MESSAGE){return s.__awaiter(this,void 0,void 0,(function*(){const n=new D(Object.assign(Object.assign(Object.assign({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:t},_),i),{replyType:s.ReplyType.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),r=yield this._requestQueue.send(n),{messages:l}=r.as(L),d=l.slice(1);return d.forEach((s=>{s.parentMessage=e})),this._dispatcher.dispatch(new s.MessageUpdateEventCommand({messages:d,source:a})),{parentMessage:l[0],threadedMessages:d}}))}getMessageChangelogs(e,t,i,a,n=s.MessageEventSource.REQUEST_MESSAGE_CHANGELOGS){return s.__awaiter(this,void 0,void 0,(function*(){const r=new k(s.deundefined(s.undefineNullProps(Object.assign(Object.assign({channelType:t,channelUrl:e,timestamp:"number"==typeof i?i:null,token:"string"==typeof i?i:null},R),a)))),l=yield this._requestQueue.send(r),{updatedMessages:d,deletedMessagesInfo:o,hasMore:u,nextToken:h}=l.as(z),p=o.map((e=>e.messageId));return d.length>0&&this._dispatcher.dispatch(new s.MessageUpdateEventCommand({messages:d,source:n})),p.length>0&&this._dispatcher.dispatch(new s.MessageRemoveEventCommand({messageIds:p,source:n})),{updatedMessages:d,deletedMessageIds:p,hasMore:u,token:h}}))}}class ${constructor(){this._onPending=s.noop,this._onFailed=s.noop,this._onSucceeded=s.noop}_trigger(e){switch(null==e?void 0:e.sendingStatus){case s.SendingStatus.PENDING:0===e.errorCode&&this._onPending(e);break;case s.SendingStatus.SCHEDULED:case s.SendingStatus.SUCCEEDED:this._onSucceeded(e)}}_triggerFailed(e,t){switch(null==t?void 0:t.sendingStatus){case s.SendingStatus.FAILED:case s.SendingStatus.CANCELED:this._onFailed(e,t.scheduledInfo?null:t)}}onPending(e){return this._onPending=e,this}onFailed(e){return this._onFailed=e,this}onSucceeded(e){return this._onSucceeded=e,this}}class H extends s.InstancedObject{constructor(e,t){super(e),this.targetMessageId=0;const i=t.thread_info,n=t.parent_message_id,r=t.channel_url,l=t.channel_type;i&&s.isTypeOf("object",i)&&s.isTypeOf("number",n)&&s.isTypeOf("string",r)&&s.isTypeOf("string",l)&&(this.threadInfo=new a(e,i),this.targetMessageId=n,this.channelUrl=r,this.channelType=l)}}const W={channelUrl:"",channelType:s.ChannelType.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1};class V extends s.APIRequestCommand{constructor({channelCustomType:e,keyword:t,limit:i,reverse:a,exactMatch:n,channelUrl:r,order:l,messageTimestampFrom:d,messageTimestampTo:o,advancedQuery:u,targetFields:h,nextToken:p}){super(),this.method=s.APIRequestMethod.GET,this.path=`${s.API_PATH_SEARCH}/messages`,this.params={custom_type:e,query:t,limit:i,reverse:a,exact_match:n,channel_url:r,message_ts_from:d,message_ts_to:o,sort_field:l,advanced_query:u,target_fields:h,after:p}}}class K extends s.APIResponseCommand{constructor(e,s){super(e,s),this.messages=s.results.map((s=>O(e,s))),this.hasNext=s.has_next,this.nextToken=s.end_cursor,this.totalCount=s.total_count}}var X;exports.MessageSearchOrder=void 0,(X=exports.MessageSearchOrder||(exports.MessageSearchOrder={})).SCORE="score",X.TIMESTAMP="ts";class J extends s.BaseListQuery{constructor(e,s){var t,i,a,n,r,l,d,o,u;super(e,s),this.keyword="",this.reverse=!1,this.exactMatch=!1,this.channelUrl="",this.channelCustomType="",this.messageTimestampFrom=null,this.messageTimestampTo=null,this.order=exports.MessageSearchOrder.SCORE,this.advancedQuery=!1,this.targetFields=null,this._nextToken="",this.totalCount=-1,this.keyword=s.keyword,this.reverse=null!==(t=s.reverse)&&void 0!==t&&t,this.exactMatch=null!==(i=s.exactMatch)&&void 0!==i&&i,this.channelUrl=null!==(a=s.channelUrl)&&void 0!==a?a:"",this.channelCustomType=null!==(n=s.channelCustomType)&&void 0!==n?n:"",this.messageTimestampFrom=null!==(r=s.messageTimestampFrom)&&void 0!==r?r:null,this.messageTimestampTo=null!==(l=s.messageTimestampTo)&&void 0!==l?l:null,this.order=null!==(d=s.order)&&void 0!==d?d:exports.MessageSearchOrder.SCORE,this.advancedQuery=null!==(o=s.advancedQuery)&&void 0!==o&&o,this.targetFields=null!==(u=s.targetFields)&&void 0!==u?u:null}_validate(){return super._validate()&&s.isTypeOf("string",this.keyword)&&this.keyword.length>0&&s.isTypeOf("boolean",this.reverse)&&s.isTypeOf("boolean",this.exactMatch)&&s.isTypeOf("string",this.channelUrl)&&s.isTypeOf("string",this.channelCustomType)&&(s.isTypeOf("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(s.isTypeOf("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&s.isEnumOf(exports.MessageSearchOrder,this.order)&&s.isTypeOf("boolean",this.advancedQuery)&&s.isArrayOf("string",this.targetFields,!0)}next(){return s.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw s.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:e}=s.Vault.of(this._iid),t=new V(s.undefineNullProps(Object.assign(Object.assign({},this),{nextToken:this._nextToken?this._nextToken:null}))),i=yield e.send(t),{messages:a,hasNext:n,nextToken:r,totalCount:l}=i.as(K);return this._nextToken=r,this._hasNext=n,this._isLoading=!1,this.totalCount=l,a}return[]}throw s.SendbirdError.invalidParameters}))}}class Y extends s.ChannelDataListQuery{constructor(e,t,i,a){var n,r,l,d,o,u,h,p,c,m;super(e,t,i,a),this.reverse=!1,this.messageTypeFilter=s.MessageTypeFilter.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=s.ReplyType.NONE,this.includeMetaArray=!1,this.includeReactions=!1,this.includeParentMessageInfo=!1,this.includeThreadInfo=!1,this.showSubchannelMessagesOnly=!1,this._edge=Number.MAX_SAFE_INTEGER,this.reverse=null!==(n=a.reverse)&&void 0!==n&&n,this.messageTypeFilter=null!==(r=a.messageTypeFilter)&&void 0!==r?r:s.MessageTypeFilter.ALL,this.customTypesFilter=null!==(l=a.customTypesFilter)&&void 0!==l?l:null,this.senderUserIdsFilter=null!==(d=a.senderUserIdsFilter)&&void 0!==d?d:null,this.replyType=null!==(o=a.replyType)&&void 0!==o?o:s.ReplyType.NONE,this.includeMetaArray=null!==(u=a.includeMetaArray)&&void 0!==u&&u,this.includeReactions=null!==(h=a.includeReactions)&&void 0!==h&&h,this.includeParentMessageInfo=null!==(p=a.includeParentMessageInfo)&&void 0!==p&&p,this.includeThreadInfo=null!==(c=a.includeThreadInfo)&&void 0!==c&&c,this.showSubchannelMessagesOnly=null!==(m=a.showSubchannelMessagesOnly)&&void 0!==m&&m}_validate(){return super._validate()&&s.isTypeOf("boolean",this.reverse)&&s.isEnumOf(s.MessageTypeFilter,this.messageTypeFilter)&&s.isEnumOf(s.ReplyType,this.replyType)&&s.isArrayOf("string",this.customTypesFilter,!0)&&s.isArrayOf("string",this.senderUserIdsFilter,!0)&&s.isTypeOf("boolean",this.includeMetaArray)&&s.isTypeOf("boolean",this.includeReactions)&&s.isTypeOf("boolean",this.includeParentMessageInfo)&&s.isTypeOf("boolean",this.includeThreadInfo)&&s.isTypeOf("boolean",this.showSubchannelMessagesOnly)}load(){return s.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw s.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const e=B.of(this._iid),t=yield e.getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,s.undefineNullProps({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}));return this._edge=Math.min(Number.MAX_SAFE_INTEGER,...t.map((e=>e.createdAt))),this._hasNext=t.length>=this.limit,this._isLoading=!1,t}return[]}throw s.SendbirdError.invalidParameters}))}}exports.AdminMessage=v,exports.AppleCriticalAlertOptions=o,exports.BaseMessage=m,exports.FileMessage=A,exports.FileMessageEventCommand=U,exports.MessageChangeLogsParamsDefault=R,exports.MessageListParamsDefault=N,exports.MessageManager=B,exports.MessageMetaArray=r,exports.MessageRequestHandler=$,exports.MessageRetrievalParamsDefault=W,exports.MessageSearchQuery=J,exports.MultipleFilesMessage=S,exports.MultipleFilesMessageRequestHandler=class extends ${constructor(){super(...arguments),this._onFileUploaded=s.noop}_triggerOnFileUploaded(e,s,t,i){this._onFileUploaded(e,s,t,i)}onFileUploaded(e){return this._onFileUploaded=e,this}onPending(e){return super.onPending(e),this}onFailed(e){return super.onFailed(e),this}onSucceeded(e){return super.onSucceeded(e),this}},exports.OGImage=l,exports.OGMetaData=d,exports.Plugin=I,exports.PreviousMessageListQuery=Y,exports.Reaction=n,exports.ReactionEvent=class{constructor(e){this.messageId=0,this.operation=null,this.updatedAt=0;const t=s.isTypeOf("string",e.msg_id)?parseInt(e.msg_id):e.msg_id,i=e.user_id,a=e.operation?e.operation.toLowerCase():null,n=e.reaction,r=e.updated_at;t&&s.isTypeOf("string",i)&&s.isTypeOf("string",a)&&s.isEnumOf(exports.ReactionEventOperation,a)&&s.isTypeOf("string",n)&&n&&s.isTypeOf("number",r)&&(this.messageId=t,this.userId=i,this.key=n,this.operation=a,this.updatedAt=r)}},exports.SendableMessage=g,exports.Sender=u,exports.ThreadInfo=a,exports.ThreadInfoUpdateEvent=H,exports.Thumbnail=y,exports.UploadFileRequestCommand=t,exports.UploadFileResponseCommand=i,exports.UploadedFileInfo=M,exports.UserMessage=T,exports.parseMessagePayload=O,exports.payloadifyMessage=e=>{switch(e.messageType){case s.MessageType.USER:return T.payloadify(e);case s.MessageType.FILE:return e.fileInfoList?S.payloadify(e):A.payloadify(e);case s.MessageType.ADMIN:return v.payloadify(e);default:throw s.SendbirdError.unknown}},exports.validateMessageChangeLogsParams=e=>s.isEnumOf(s.ReplyType,e.replyType)&&s.isTypeOf("boolean",e.includeReactions)&&s.isTypeOf("boolean",e.includeMetaArray)&&s.isTypeOf("boolean",e.includeParentMessageInfo)&&s.isTypeOf("boolean",e.includeThreadInfo),exports.validateMessageListParams=e=>s.isTypeOf("number",e.prevResultSize)&&s.isTypeOf("number",e.nextResultSize)&&s.isTypeOf("boolean",e.isInclusive)&&s.isTypeOf("boolean",e.reverse)&&s.isTypeOf("string",e.messageTypeFilter)&&s.isEnumOf(s.MessageTypeFilter,e.messageTypeFilter)&&s.isArrayOf("string",e.customTypesFilter,!0)&&s.isArrayOf("string",e.senderUserIdsFilter,!0)&&s.isEnumOf(s.ReplyType,e.replyType)&&s.isTypeOf("boolean",e.includeMetaArray)&&s.isTypeOf("boolean",e.includeReactions)&&s.isTypeOf("boolean",e.includeParentMessageInfo)&&s.isTypeOf("boolean",e.includeThreadInfo)&&s.isTypeOf("boolean",e.showSubchannelMessagesOnly),exports.validateMessageRetrievalParams=e=>s.isTypeOf("string",e.channelUrl)&&s.isEnumOf(s.ChannelType,e.channelType)&&s.isTypeOf("number",e.messageId)&&s.isTypeOf("boolean",e.includeReactions,!0)&&s.isTypeOf("boolean",e.includeMetaArray,!0)&&s.isTypeOf("boolean",e.includeParentMessageInfo,!0)&&s.isTypeOf("boolean",e.includeThreadInfo,!0); diff --git a/cjs/lib/__bundle-91cccea4.js b/cjs/lib/__bundle-91cccea4.js new file mode 100644 index 0000000..c4a521b --- /dev/null +++ b/cjs/lib/__bundle-91cccea4.js @@ -0,0 +1 @@ +"use strict";var s=require("./__bundle-032c97c6.js");class t extends s.User{constructor(s,t){var e;super(s,t),this.isMuted=!1,this.isMuted=null!==(e=t.is_muted)&&void 0!==e&&e}}exports.Participant=t; diff --git a/cjs/lib/__bundle-aa0921e3.js b/cjs/lib/__bundle-aa0921e3.js new file mode 100644 index 0000000..5a3dc01 --- /dev/null +++ b/cjs/lib/__bundle-aa0921e3.js @@ -0,0 +1 @@ +"use strict";var e=require("./__bundle-032c97c6.js"),s=require("./__bundle-7e34e7ed.js"),t=require("./__bundle-481ecf03.js");const n={data:void 0,customType:void 0,mentionType:e.MentionType.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,mentionedMessageTemplate:void 0,metaArrays:void 0,parentMessageId:void 0,isReplyToChannel:!1,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0,isPinnedMessage:!1},a=t=>e.isTypeOf("string",t.data,!0)&&e.isTypeOf("string",t.customType,!0)&&e.isEnumOf(e.MentionType,t.mentionType)&&e.isArrayOf("string",t.mentionedUserIds,!0)&&e.isArrayOf(e.User,t.mentionedUsers,!0)&&e.isTypeOf("string",t.mentionedMessageTemplate,!0)&&e.isArrayOf(s.MessageMetaArray,t.metaArrays,!0)&&e.isTypeOf("number",t.parentMessageId,!0)&&e.isTypeOf("boolean",t.isReplyToChannel)&&e.isEnumOf(e.PushNotificationDeliveryOption,t.pushNotificationDeliveryOption,!0)&&e.isTypeOf(s.AppleCriticalAlertOptions,t.appleCriticalAlertOptions,!0)&&e.isTypeOf("boolean",t.isPinnedMessage,!0),i=Object.assign(Object.assign({},n),{message:"",translationTargetLanguages:void 0,pollId:void 0}),r=s=>a(s)&&e.isTypeOf("string",s.message)&&e.isArrayOf("string",s.translationTargetLanguages,!0)&&e.isTypeOf("number",s.pollId,!0);var o;exports.FileType=void 0,(o=exports.FileType||(exports.FileType={})).FILE="file",o.BLOB="blob",o.BLOB_LIKE_OBJECT="blobLikeObject",o.URL="url";const d=Object.assign(Object.assign({},n),{file:void 0,fileKey:void 0,fileUrl:void 0,fileName:void 0,fileType:void 0,fileSize:void 0,mimeType:void 0,thumbnailSizes:void 0,requireAuth:!1}),l=s=>a(s)&&(e.isFile(s.file)||e.isTypeOf("string",s.fileUrl))&&e.isTypeOf("string",s.fileName,!0)&&e.isTypeOf("string",s.mimeType,!0)&&e.isTypeOf("number",s.fileSize,!0)&&(null===s.thumbnailSizes||void 0===s.thumbnailSizes||Array.isArray(s.thumbnailSizes)&&s.thumbnailSizes.every((s=>e.isTypeOf("object",s)&&s.maxWidth>0&&s.maxHeight>0))),u=Object.assign(Object.assign({},n),{fileInfoList:[]}),c=s=>(e.isFile(s.file)||e.isTypeOf("string",s.fileUrl))&&e.isTypeOf("string",s.fileName,!0)&&e.isTypeOf("string",s.mimeType,!0)&&e.isTypeOf("number",s.fileSize,!0)&&(void 0===s.thumbnailSizes||Array.isArray(s.thumbnailSizes)&&s.thumbnailSizes.every((e=>e.maxWidth>0&&e.maxHeight>0)));var h;exports.RestrictionType=void 0,(h=exports.RestrictionType||(exports.RestrictionType={})).MUTED="muted",h.BANNED="banned";class p{constructor(s){var t,n,a,i;this.restrictionType=null,e.isEnumOf(exports.RestrictionType,s.restriction_type)&&(this.restrictionType=s.restriction_type),this.description=null!==(t=s.description)&&void 0!==t?t:null,this.endAt=null!==(a=null!==(n=s.end_at)&&void 0!==n?n:s.muted_end_at)&&void 0!==a?a:-1,this.remainingDuration=null!==(i=s.remaining_duration)&&void 0!==i?i:-1}static payloadify(s){return e.deundefined(e.undefineNullProps({restriction_type:s.restrictionType,description:s.description,end_at:s.endAt,remaining_duration:s.remainingDuration}))}}class m extends e.User{constructor(e,s){super(e,s),this.restrictionInfo=new p(s)}static payloadify(s){return e.deundefined(e.undefineNullProps(Object.assign(Object.assign({},super.payloadify(s)),p.payloadify(s.restrictionInfo))))}}const g={data:void 0,customType:void 0,mentionType:e.MentionType.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,mentionedMessageTemplate:void 0,metaArrays:void 0,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0},y=t=>e.isTypeOf("string",t.data,!0)&&e.isTypeOf("string",t.customType,!0)&&e.isEnumOf(e.MentionType,t.mentionType)&&e.isArrayOf("string",t.mentionedUserIds,!0)&&e.isArrayOf(e.User,t.mentionedUsers,!0)&&e.isTypeOf("string",t.mentionedMessageTemplate,!0)&&e.isArrayOf(s.MessageMetaArray,t.metaArrays,!0)&&e.isEnumOf(e.PushNotificationDeliveryOption,t.pushNotificationDeliveryOption,!0)&&e.isTypeOf(s.AppleCriticalAlertOptions,t.appleCriticalAlertOptions,!0),_=Object.assign(Object.assign({},g),{message:void 0,translationTargetLanguages:void 0,pollId:void 0}),f=s=>y(s)&&e.isTypeOf("string",s.message,!0)&&e.isArrayOf("string",s.translationTargetLanguages,!0)&&e.isTypeOf("number",s.pollId,!0),v=Object.assign({},g);class T extends e.APIRequestCommand{constructor({channelUrl:s,channelType:t,token:n,limit:a}){super(),this.method=e.APIRequestMethod.GET,this.path=`${e.getChannelApiPathByType(t)}/${encodeURIComponent(s)}/operators`,this.params={token:n,limit:a}}}class M extends e.APIResponseCommand{constructor(s,t){super(s,t),this.operators=t.operators.map((t=>new e.User(s,t))),this.token=t.next}}class I extends e.ChannelDataListQuery{constructor(e,s,t,n){super(e,s,t,n)}_validate(){return super._validate()}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;{const s=[];if(this._hasNext){this._isLoading=!0;const{requestQueue:s}=e.Vault.of(this._iid),t=new T(Object.assign(Object.assign({},this),{channelUrl:this.channelUrl,token:this._token})),n=yield s.send(t),{operators:a,token:i}=n.as(M);return this._token=i,this._hasNext=!!i,this._isLoading=!1,a}return s}}throw e.SendbirdError.invalidParameters}))}}class E extends e.APIRequestCommand{constructor(s){const{channelUrl:t,channelType:n,limit:a,token:i}=s;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(t)}/mute`,this.params={limit:a,token:i}}}class A extends e.APIResponseCommand{constructor(e,s){super(e,s),this.mutedUsers=[];const{next:t,muted_list:n}=s;this.token=t,n&&n.length>0&&(this.mutedUsers=n.map((s=>new m(e,s))))}}class P extends e.ChannelDataListQuery{constructor(e,s,t,n){super(e,s,t,n)}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:s}=e.Vault.of(this._iid),t=new E(Object.assign(Object.assign({},this),{token:this._token})),n=yield s.send(t),{mutedUsers:a,token:i}=n.as(A);return this._token=i,this._hasNext=!!i,this._isLoading=!1,a}return[]}throw e.SendbirdError.invalidParameters}))}}class U extends e.APIRequestCommand{constructor(s){const{channelUrl:t,channelType:n,limit:a,token:i}=s;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(t)}/ban`,this.params=e.deundefined({limit:a,token:i})}}class C extends e.APIResponseCommand{constructor(e,s){super(e,s),this.bannedUsers=[];const{next:t,banned_list:n}=s;this.token=t,n&&n.length>0&&(this.bannedUsers=n.map((s=>new m(e,s.user))))}}class S extends e.ChannelDataListQuery{constructor(e,s,t,n){super(e,s,t,n)}_validate(){return super._validate()}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:s}=e.Vault.of(this._iid),t=new U(Object.assign(Object.assign({},this),{token:this._token})),n=yield s.send(t),{bannedUsers:a,token:i}=n.as(C);return this._token=i,this._hasNext=!!i,this._isLoading=!1,a}return[]}throw e.SendbirdError.invalidParameters}))}}var O;exports.ReportCategory=void 0,(O=exports.ReportCategory||(exports.ReportCategory={})).SPAM="spam",O.HARASSING="harassing",O.SUSPICIOUS="suspicious",O.INAPPROPRIATE="inappropriate";class w extends e.APIRequestCommand{constructor(s){const{channelUrl:t,channelType:n,operatorUserIds:a}=s;super(),this.method=e.APIRequestMethod.POST,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(t)}/operators`,this.params={operator_ids:a}}}class b extends e.APIRequestCommand{constructor(s){const{channelUrl:t,channelType:n,operatorUserIds:a}=s;super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(t)}/operators`,this.params={operator_ids:a}}}class R extends e.APIRequestCommand{constructor(s){const{channelUrl:t,channelType:n,userId:a}=s;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(t)}/mute/${a}`}}class q extends e.APIResponseCommand{constructor(e,s){super(e,s),this.isMuted=!1,this.startAt=0,this.endAt=0;const{is_muted:t,start_at:n,end_at:a,remaining_duration:i,description:r}=s;this.isMuted=t,this.startAt=n,this.endAt=a,this.remainingDuration=i,this.description=r}}class x extends e.APIRequestCommand{constructor(s){const{channelUrl:t,channelType:n,keys:a}=s;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(t)}/metadata`,this.params={keys:a,include_ts:!0}}}class L extends e.APIResponseCommand{constructor(e,s){super(e,s);const{metadata:t,ts:n}=s;this.metadata=t,this.ts=n}}class D extends e.APIRequestCommand{constructor(s){const{channelUrl:t,channelType:n,metadata:a}=s;super(),this.method=e.APIRequestMethod.POST,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(t)}/metadata`,this.params={metadata:a,include_ts:!0}}}class N extends e.APIResponseCommand{constructor(e,s){var t,n;super(e,s),this.metaData=null!==(t=s.metadata)&&void 0!==t?t:{},this.ts=null!==(n=s.ts)&&void 0!==n?n:null}}class F extends e.APIRequestCommand{constructor(s){const{channelUrl:t,channelType:n,metadata:a,upsert:i}=s;super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(t)}/metadata`,this.params={metadata:a,include_ts:!0,upsert:null!=i&&i}}}class k extends e.APIResponseCommand{constructor(e,s){super(e,s);const{metadata:t,ts:n}=s;this.metadata=t,this.ts=n}}class V extends e.WebSocketEventCommand{constructor(e,s,t){super(e,"SYEV",t),t.data&&(this.created=t.data.created,this.updated=t.data.updated,this.deleted=t.data.deleted)}}class $ extends e.APIRequestCommand{constructor(s){const{channelUrl:t,channelType:n,key:a}=s;super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(t)}/metadata/${a}`,this.params={include_ts:!0}}}class j extends e.APIResponseCommand{constructor(e,s){super(e,s);const{ts:t}=s;this.ts=t}}class B extends e.APIRequestCommand{constructor(s){const{channelUrl:t,channelType:n}=s;super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(t)}/metadata`,this.params={include_ts:!0}}}class Q extends e.APIResponseCommand{constructor(e,s){super(e,s);const{ts:t}=s;this.ts=t}}class z extends e.APIRequestCommand{constructor(s){const{channelUrl:t,channelType:n,keys:a}=s;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(t)}/metacounter`,this.params={keys:a}}}class G extends e.APIResponseCommand{constructor(e,s){super(e,s),this.metaCounter=s}}class W extends e.APIRequestCommand{constructor(s){const{channelUrl:t,channelType:n,metaCounter:a}=s;super(),this.method=e.APIRequestMethod.POST,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(t)}/metacounter`,this.params={metacounter:a}}}class H extends e.APIResponseCommand{constructor(e,s){super(e,s),this.metaCounter=s}}class K extends e.APIRequestCommand{constructor(s){const{channelUrl:t,channelType:n,metaCounter:a,upsert:i=!1,mode:r="set"}=s;super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(t)}/metacounter`,this.params={metacounter:a,upsert:i,mode:r}}}class Y extends e.APIResponseCommand{constructor(e,s){super(e,s),this.metaCounter=s}}class J extends e.WebSocketEventCommand{constructor(e,s,t){super(e,"SYEV",t),t.data&&(this.created=t.data.created,this.updated=t.data.updated,this.deleted=t.data.deleted)}}class X extends e.APIRequestCommand{constructor(s){const{channelUrl:t,channelType:n,key:a}=s;super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(t)}/metacounter/${a}`,this.params={}}}class Z extends e.APIRequestCommand{constructor(s){const{channelUrl:t,channelType:n}=s;super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(t)}/metacounter`,this.params={}}}class ee extends e.APIRequestCommand{constructor(s){const{channelUrl:t,channelType:n,userId:a,seconds:i,description:r}=s;super(),this.method=e.APIRequestMethod.POST,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(t)}/mute`,this.params={user_id:a,seconds:i,description:r}}}class se extends e.WebSocketEventCommand{constructor(e,s,t){super(e,"SYEV",t),this.user=new m(e,t.data)}}class te extends e.APIRequestCommand{constructor(s){const{channelUrl:t,channelType:n,userId:a}=s;super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(t)}/mute/${encodeURIComponent(a)}`}}class ne extends e.WebSocketEventCommand{constructor(e,s,t){super(e,"SYEV",t),this.user=new m(e,t.data)}}class ae extends e.APIRequestCommand{constructor(s){const{channelUrl:t,channelType:n,userId:a,seconds:i,description:r}=s;super(),this.method=e.APIRequestMethod.POST,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(t)}/ban`,this.params=e.deundefined({user_id:a,seconds:i,description:r})}}class ie extends e.WebSocketEventCommand{constructor(e,s,t){super(e,"SYEV",t),this.user=new m(e,t.data),t.data.member_count&&(this.memberCount=t.data.member_count),t.data.joined_member_count&&(this.joinedMemberCount=t.data.joined_member_count)}}class re extends e.APIRequestCommand{constructor(s){const{channelUrl:t,channelType:n,userId:a}=s;super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(t)}/ban/${encodeURIComponent(a)}`}}class oe extends e.WebSocketEventCommand{constructor(e,s,t){super(e,"SYEV",t),this.user=new m(e,t.data)}}class de extends e.APIRequestCommand{constructor(s){const{channelUrl:t,channelType:n,freezing:a}=s;super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.getChannelApiPathByType(n)}/${encodeURIComponent(t)}/freeze`,this.params={freeze:a}}}class le extends e.WebSocketEventCommand{constructor(e,s,t){super(e,"SYEV",t),this.freeze=t.data.freeze}}class ue extends e.APIRequestCommand{constructor(s){const{channelUrl:t,channelType:n,category:a,userId:i,description:r}=s;super(),this.method=e.APIRequestMethod.POST,this.path=`${e.getReportApiPathByType(n)}/${encodeURIComponent(t)}`,this.params={report_category:a,reporting_user_id:i,report_description:r}}}class ce extends e.APIRequestCommand{constructor(s){const{channelUrl:t,channelType:n,category:a,userId:i,offendingUserId:r,description:o}=s;super(),this.method=e.APIRequestMethod.POST,this.path=`${e.API_PATH_REPORT}/users/${r}`,this.params={channel_url:t,channel_type:n===e.ChannelType.OPEN?"open_channels":"group_channels",report_category:a,reporting_user_id:i,report_description:o}}}class he extends e.APIRequestCommand{constructor(s){const{channelUrl:t,channelType:n,category:a,userId:i,offendingUserId:r,messageId:o,description:d}=s;super(),this.method=e.APIRequestMethod.POST,this.path=`${e.getReportApiPathByType(n)}/${encodeURIComponent(t)}/messages/${o}`,this.params={report_category:a,reporting_user_id:i,report_description:d,offending_user_id:r}}}class pe extends e.WebSocketRequestCommand{constructor(s){let t=[];s.mentionType===e.MentionType.USERS&&(s.mentionedUserIds?t=s.mentionedUserIds:s.mentionedUsers&&(t=s.mentionedUsers.map((e=>e.userId)))),super({code:"MESG",ackRequired:!0,payload:e.deundefined(e.undefineNullProps({channel_url:s.channelUrl,message:s.message,data:s.data,custom_type:s.customType,metaarray:s.metaArrays,mention_type:s.mentionType,mentioned_user_ids:t,mentioned_message_template:s.mentionedMessageTemplate,target_langs:s.translationTargetLanguages,push_option:s.pushNotificationDeliveryOption&&s.pushNotificationDeliveryOption!==e.PushNotificationDeliveryOption.DEFAULT?s.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:s.appleCriticalAlertOptions,silent:s.silent,reply_to_channel:s.isReplyToChannel,parent_message_id:s.parentMessageId?s.parentMessageId:null,req_id:s.reqId,poll_id:s.pollId,pin_message:s.isPinnedMessage}))})}}class me extends e.WebSocketEventCommand{constructor(t,n,a){var i,r,o,d;super(t,"MESG",a),this.message=new s.UserMessage(t,a);const{sdkState:l}=e.Vault.of(t);this.isMentioned=e.checkIfMentioned(this.message.mentionType,null!==(o=null!==(i=this.message.mentionedUserIds)&&void 0!==i?i:null===(r=this.message.mentionedUsers)||void 0===r?void 0:r.map((e=>e.userId)))&&void 0!==o?o:[],l.userId),this.forceUpdateLastMessage=null!==(d=a.force_update_last_message)&&void 0!==d&&d}}class ge extends e.WebSocketRequestCommand{constructor(t){let n=null;t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?n=t.mentionedUserIds:t.mentionedUsers&&(n=t.mentionedUsers.map((e=>e.userId)))),super({code:"MEDI",ackRequired:!0,payload:e.deundefined(e.undefineNullProps({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:n,mentioned_message_template:t.mentionedMessageTemplate,apple_critical_alert_options:t.appleCriticalAlertOptions?s.AppleCriticalAlertOptions.payloadify(t.appleCriticalAlertOptions):null,poll_id:t.pollId}))})}}class ye extends e.WebSocketEventCommand{constructor(t,n,a){var i,r,o,d,l;super(t,"MEDI",a),this.message=new s.UserMessage(t,a);const{sdkState:u}=e.Vault.of(t);this.mentionCountChange=e.calculateMentionCountChange({mentionType:null===(i=a.old_values)||void 0===i?void 0:i.mention_type,mentionedUserIds:null!==(o=null===(r=a.old_values)||void 0===r?void 0:r.mentioned_user_ids)&&void 0!==o?o:[]},e.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(d=this.message.mentionedUserIds)&&void 0!==d?d:null===(l=this.message.mentionedUsers)||void 0===l?void 0:l.map((e=>e.userId))}),u.userId)}}class _e extends e.WebSocketRequestCommand{constructor(s){let t=null;s.mentionType===e.MentionType.USERS&&(s.mentionedUserIds?t=s.mentionedUserIds:s.mentionedUsers&&(t=s.mentionedUsers.map((e=>e.userId)))),super({code:"FEDI",ackRequired:!0,payload:e.deundefined(e.undefineNullProps({channel_url:s.channelUrl,msg_id:s.messageId,data:s.data,custom_type:s.customType,metaarray:s.metaArrayParams,mention_type:s.mentionType,mentioned_user_ids:t,apple_critical_alert_options:s.appleCriticalAlertOptions}))})}}class fe extends e.WebSocketEventCommand{constructor(t,n,a){var i,r,o,d,l;super(t,"FEDI",a),this.message=new s.FileMessage(t,a);const{sdkState:u}=e.Vault.of(t);this.mentionCountChange=e.calculateMentionCountChange({mentionType:null===(i=a.old_values)||void 0===i?void 0:i.mention_type,mentionedUserIds:null!==(o=null===(r=a.old_values)||void 0===r?void 0:r.mentioned_user_ids)&&void 0!==o?o:[]},e.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(d=this.message.mentionedUserIds)&&void 0!==d?d:null===(l=this.message.mentionedUsers)||void 0===l?void 0:l.map((e=>e.userId))}),u.userId)}}class ve extends e.APIRequestCommand{constructor(s){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.getChannelApiPathByType(s.channelType)}/${s.channelUrl}/messages/${s.messageId}`}}class Te extends e.WebSocketEventCommand{constructor(e,s,t){super(e,"DELM",t),this.channelUrl=t.channel_url,this.channelType=t.channel_type,this.messageId=Number(t.msg_id)}}class Me extends e.APIRequestCommand{constructor({channelType:s,channelUrl:t,messageId:n,reactionKey:a}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.getChannelApiPathByType(s)}/${encodeURIComponent(t)}/messages/${n}/reactions`,this.params={reaction:a}}}class Ie extends e.APIResponseCommand{constructor(e,t){super(e,t),this.reactionEvent=new s.ReactionEvent(t)}}class Ee extends e.APIRequestCommand{constructor({channelType:s,channelUrl:t,messageId:n,reactionKey:a}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.getChannelApiPathByType(s)}/${encodeURIComponent(t)}/messages/${n}/reactions`,this.params={reaction:a}}}class Ae extends e.APIResponseCommand{constructor(e,t){super(e,t),this.reactionEvent=new s.ReactionEvent(Object.assign({},t))}}class Pe extends e.APIRequestCommand{constructor({channelType:s,channelUrl:t,messageId:n,translationTargetLanguages:a}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.getChannelApiPathByType(s)}/${encodeURIComponent(t)}/messages/${encodeURIComponent(n)}/translation`,this.params={target_langs:a}}}class Ue extends e.APIResponseCommand{constructor(e,t){super(e,t),this.message=new s.UserMessage(e,t)}}class Ce extends e.APIRequestCommand{constructor(t){var n;super();let a=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?a=t.mentionedUserIds:t.mentionedUsers&&(a=t.mentionedUsers.map((e=>e.userId))));const{channelType:i,channelUrl:r}=t;this.method=e.APIRequestMethod.POST,this.path=`${e.getChannelApiPathByType(i)}/${encodeURIComponent(r)}/scheduled_messages`,this.params=e.deundefined(e.undefineNullProps({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:e.ServerSideMessageType.USER,message:t.message,custom_type:t.customType,data:t.data,mention_type:t.mentionType,mentioned_user_ids:a,sorted_metaarray:null===(n=t.metaArrays)||void 0===n?void 0:n.map((e=>s.MessageMetaArray.payloadify(e))),apple_critical_alert_options:t.appleCriticalAlertOptions?s.AppleCriticalAlertOptions.payloadify(t.appleCriticalAlertOptions):null,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption}))}}class Se extends e.APIResponseCommand{constructor(e,t){super(e,t),this.message=new s.UserMessage(e,t)}}class Oe extends e.APIRequestCommand{constructor(t){var n;super();let a=[];t.mentionType===e.MentionType.USERS&&(t.mentionedUserIds?a=t.mentionedUserIds:t.mentionedUsers&&(a=t.mentionedUsers.map((e=>e.userId))));const{channelType:i,channelUrl:r}=t;this.method=e.APIRequestMethod.POST,this.path=`${e.getChannelApiPathByType(i)}/${encodeURIComponent(r)}/scheduled_messages`,this.params=e.undefineNullProps({req_id:t.reqId,scheduled_at:t.scheduledAt,message_type:e.ServerSideMessageType.FILE,url:t.fileUrl,file_name:t.fileName,file_size:t.fileSize,file_type:t.mimeType,thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((e=>s.Thumbnail.payloadify(e))):[],custom_type:t.customType,data:t.data,require_auth:t.requireAuth,mention_type:t.mentionType,mentioned_user_ids:a,sorted_metaarray:null===(n=t.metaArrays)||void 0===n?void 0:n.map((e=>s.MessageMetaArray.payloadify(e))),apple_critical_alert_options:t.appleCriticalAlertOptions?s.AppleCriticalAlertOptions.payloadify(t.appleCriticalAlertOptions):null,push_option:t.pushNotificationDeliveryOption})}}class we extends e.APIResponseCommand{constructor(e,t){super(e,t),this.message=new s.FileMessage(e,t)}}class be extends e.APIRequestCommand{constructor({pollId:s,title:t,data:n,allowUserSuggestion:a,allowMultipleVotes:i,closeAt:r}){super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_POLLS}/${encodeURIComponent(s)}`,this.params={title:t,data:n,allow_user_suggestion:a,allow_multiple_votes:i,close_at:r}}}class Re extends e.APIResponseCommand{constructor(s,t){super(s,t),this.poll=new e.Poll(s,t)}}class qe extends e.APIRequestCommand{constructor({pollId:s}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_POLLS}/${encodeURIComponent(s)}`}}class xe extends e.APIRequestCommand{constructor({pollId:s}){super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_POLLS}/${encodeURIComponent(s)}/close`}}class Le extends e.APIResponseCommand{constructor(s,t){super(s,t),this.poll=new e.Poll(s,t)}}class De extends e.APIRequestCommand{constructor({channelUrl:s,channelType:t,pollId:n,optionText:a}){super(),this.method=e.APIRequestMethod.POST,this.path=`${e.API_PATH_POLLS}/${encodeURIComponent(n)}/options`,this.params={channel_url:s,channel_type:t,text:a}}}class Ne extends e.APIResponseCommand{constructor(s,t){super(s,t),this.poll=new e.Poll(s,t)}}class Fe extends e.APIRequestCommand{constructor({pollId:s,pollOptionId:t,optionText:n}){super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_POLLS}/${encodeURIComponent(s)}/options/${encodeURIComponent(t)}`,this.params={text:n}}}class ke extends e.APIResponseCommand{constructor(s,t){super(s,t),this.poll=new e.Poll(s,t)}}class Ve extends e.APIRequestCommand{constructor({pollId:s,pollOptionId:t}){super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_POLLS}/${encodeURIComponent(s)}/options/${encodeURIComponent(t)}`}}class $e extends e.WebSocketRequestCommand{constructor({reqId:s,channelType:t,channelUrl:n,pollId:a,pollOptionIds:i}){super({code:"VOTE",ackRequired:!0,payload:e.deundefined({req_id:s,channel_type:t===e.ChannelType.OPEN?"open_channels":"group_channels",channel_url:n,poll_id:a,option_ids:i})})}}class je extends e.WebSocketEventCommand{constructor(e,s,n){super(e,"VOTE",n),this.event=new t.PollVoteEvent(n),this.channelUrl=n.channel_url,this.channelType=n.channel_type}}class Be extends e.InstancedObject{constructor(s,t){var n,a,i,r;super(s),this.channelType=e.ChannelType.BASE,this.name="",this.coverUrl="",this.customType="",this.data="",this.isFrozen=!1,this.isEphemeral=!1,this.creator=null,this.createdAt=0,this._messageCollectionLastAccessedAt=0,this.url=t.channel_url,this.name=null!==(n=t.name)&&void 0!==n?n:"",this.coverUrl=null!==(a=t.cover_url)&&void 0!==a?a:"",this.customType=null!==(i=t.custom_type)&&void 0!==i?i:"",this.data=null!==(r=t.data)&&void 0!==r?r:"",this.isFrozen=!!e.isTypeOf("boolean",t.freeze)&&t.freeze,this.isEphemeral=!!e.isTypeOf("boolean",t.is_ephemeral)&&t.is_ephemeral,this.creator=t.created_by?new e.User(this._iid,t.created_by):null,this.createdAt=1e3*t.created_at,t.metadata&&Object.keys(t.metadata).length>0&&t.ts&&(this._cachedMetaData=new Map,Object.keys(t.metadata).forEach((e=>{this._cachedMetaData.set(e,{value:t.metadata[e],isRemoved:!1,updatedAt:t.ts})})))}static payloadify(s){return e.deundefined(e.undefineNullProps(Object.assign(Object.assign({},super.payloadify(s)),{channel_url:s.url,name:s.name,cover_url:s.coverUrl,custom_type:s.customType,data:s.data,freeze:s.isFrozen,is_ephemeral:s.isEphemeral,created_by:s.creator?e.User.payloadify(s.creator):null,created_at:s.createdAt/1e3})))}isGroupChannel(){return this.channelType===e.ChannelType.GROUP}isOpenChannel(){return this.channelType===e.ChannelType.OPEN}get cachedMetaData(){const e={};return this._cachedMetaData?(this._cachedMetaData.forEach(((s,t)=>{s.isRemoved||(e[t]=s.value)})),e):e}get messageCollectionLastAccessedAt(){return this._messageCollectionLastAccessedAt}_updateMessageCollectionLastAccessedAt(){this._messageCollectionLastAccessedAt=Date.now()}_update(s){const t=e.deundefined(s);Object.assign(this,t)}_upsertCachedMetaData(e,s){Object.keys(e).forEach((t=>{this._cachedMetaData||(this._cachedMetaData=new Map);const n=this._cachedMetaData.get(t);(!n||n.updatedAt<=s)&&this._cachedMetaData.set(t,{value:e[t],isRemoved:!1,updatedAt:s})}))}_removeFromCachedMetaData(e,s){this._cachedMetaData&&e.forEach((e=>{const t=this._cachedMetaData.get(e);t&&t.updatedAts.MessageMetaArray.payloadify(e))):null,apple_critical_alert_options:t.appleCriticalAlertOptions?s.AppleCriticalAlertOptions.payloadify(t.appleCriticalAlertOptions):null,created_at:a,user:r.currentUser?s.Sender.payloadify(r.currentUser):null,req_id:n,request_state:e.SendingStatus.PENDING,mentioned_user_ids:t.mentionedUserIds,mentioned_users:null===(i=t.mentionedUsers)||void 0===i?void 0:i.map((s=>e.User.payloadify(s)))}))}_createPendingUserMessage(t,n,a){const i={};if(t.translationTargetLanguages)for(const e of t.translationTargetLanguages)i[e]="";const r=e.deundefined(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,a)),{type:e.MessageType.USER,message:t.message,translations:i})),o=new s.UserMessage(this._iid,r);return o.messageParams=t,o}_createPendingScheduledUserMessage(e,s,t){const n=this._createPendingUserMessage(e,s,t);return n.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},n}_createPendingFileMessage(t,n,a){var i,r,o,d,l,u;const c=e.deundefined(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,a)),{type:e.MessageType.FILE,url:t.fileUrl,file:{name:null!==(i=t.fileName)&&void 0!==i?i:null===(r=t.file)||void 0===r?void 0:r.name,size:null!==(o=t.fileSize)&&void 0!==o?o:null===(d=t.file)||void 0===d?void 0:d.size,type:null!==(l=t.mimeType)&&void 0!==l?l:null===(u=t.file)||void 0===u?void 0:u.type,data:t.data},thumbnails:t.thumbnailSizes?t.thumbnailSizes.map((e=>({url:"",width:e.maxWidth,height:e.maxHeight}))):[]})),h=new s.FileMessage(this._iid,c);return h.messageParams=t,h}_createPendingMultipleFilesMessage(t,n,a){const i=e.deundefined(Object.assign(Object.assign({},this._createPendingSendableMessagePayload(t,n,a)),{type:e.MessageType.FILE})),r=new s.MultipleFilesMessage(this._iid,i);return r.messageParams=t,r}_createPendingScheduledFileMessage(e,s,t){const n=this._createPendingFileMessage(e,s,t);return n.scheduledInfo={scheduledMessageId:0,scheduledAt:e.scheduledAt,scheduledMessageParams:e},n}_markMessageAsFailed(s,t,n=!1){s.errorCode=t.code,t.code===e.SendbirdErrorCode.REQUEST_CANCELED||t.code===e.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED?s.sendingStatus=e.SendingStatus.CANCELED:n||(s.sendingStatus=e.SendingStatus.FAILED)}sendUserMessage(s){const t=Object.assign(Object.assign({},i),s);return e.unless(r(t)).throw(e.SendbirdError.invalidParameters),this._sendUserMessage(t)}_sendUserMessage(t,n,a=!1){const{dispatcher:i,requestQueue:r,sessionManager:o}=e.Vault.of(this._iid);let d=null!=n?n:this._generateRequestId();const l=Date.now(),u=new s.MessageRequestHandler;return d||(d=this._generateRequestId()),e.sleep(2).then((()=>{const s=this._createPendingUserMessage(t,d,l);i.dispatch(new e.MessageUpdateEventCommand({messages:[s],source:a?e.MessageEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return u._trigger(s)}))));const n=new pe(Object.assign(Object.assign({},t),{channelUrl:this.url,channelType:this.channelType,reqId:d}));r.send(n).then((s=>{const{message:t}=s.as(me);i.dispatch(new e.MessageUpdateEventCommand({messages:[t],source:e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return u._trigger(t)}))))})).catch((s=>{if(e.isThrowingOutside(s))throw s;e.sleep(2).then((()=>{const n=this._createPendingUserMessage(t,d,l),{cacheContext:a}=e.Vault.of(this._iid),r=a.localCacheEnabled&&e.isAutoResendableError(s.code);this._markMessageAsFailed(n,s,r),i.dispatch(new e.MessageUpdateEventCommand({messages:[n],source:n.sendingStatus===e.SendingStatus.PENDING?e.MessageEventSource.REQUEST_RESEND_MESSAGE:e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return u._triggerFailed(s,n)}))))}))}))})),u}_autoResendUserMessage(t){return e.unless(t instanceof s.UserMessage&&!!t.messageParams).throw(e.SendbirdError.invalidParameters),this._sendUserMessage(t.messageParams,t.reqId)}resendUserMessage(t){var n;return e.__awaiter(this,void 0,void 0,(function*(){e.unless(t instanceof s.UserMessage&&!t.scheduledInfo).throw(e.SendbirdError.invalidParameters);const a=new e.Deferred,i=null!==(n=t.messageParams)&&void 0!==n?n:(s=>{var t;return e.deundefined(e.undefineNullProps({data:s.data,customType:s.customType,mentionType:s.mentionType,mentionedUsers:s.mentionedUsers,mentionedUserIds:s.mentionedUserIds,mentionedMessageTemplate:s.mentionedMessageTemplate,metaArrays:s.metaArrays,pollId:null===(t=s.poll)||void 0===t?void 0:t.id,parentMessageId:s.parentMessageId,appleCriticalAlertOptions:s.appleCriticalAlertOptions,message:s.message,translationTargetLanguages:Object.keys(s.translations)}))})(t);return this._sendUserMessage(i,t.reqId,!0).onFailed((e=>a.reject(e))).onSucceeded((e=>a.resolve(e))),a.promise}))}updateUserMessage(s,t){return e.__awaiter(this,void 0,void 0,(function*(){const n=Object.assign(Object.assign({},_),t);e.unless(e.isTypeOf("number",s)&&f(n)).throw(e.SendbirdError.invalidParameters);const{requestQueue:a}=e.Vault.of(this._iid),i=new ge(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:s},n)),r=yield a.send(i),{message:o}=r.as(ye);return o}))}copyUserMessage(t,n){var a,i,r;return e.__awaiter(this,void 0,void 0,(function*(){e.unless(t instanceof Be&&n instanceof s.UserMessage&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(e.SendbirdError.invalidParameters),e.unless(!n.poll).throw(e.SendbirdError.notSupportedError);const o=new e.Deferred,d=null!==(a=n.messageParams)&&void 0!==a?a:e.undefineNullProps(Object.assign(Object.assign({},n),{mentionType:n.mentionType,mentionedUserIds:null!==(i=n.mentionedUserIds)&&void 0!==i?i:null===(r=n.mentionedUsers)||void 0===r?void 0:r.map((e=>e.userId)),translationTargetLanguages:Object.keys(n.translations),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,isPinnedMessage:!1}));return t._sendUserMessage(d).onSucceeded((e=>{o.resolve(e)})).onFailed((e=>o.reject(e))),o.promise}))}translateUserMessage(t,n){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(t instanceof s.UserMessage&&t.messageId>0&&e.isArrayOf("string",n)).throw(e.SendbirdError.invalidParameters);const{requestQueue:a}=e.Vault.of(this._iid),i=new Pe({channelType:this.channelType,channelUrl:this.url,messageId:t.messageId,translationTargetLanguages:n}),r=yield a.send(i),{message:o}=r.as(Ue);return o}))}_createScheduledUserMessage(s,t){const{requestQueue:n}=e.Vault.of(this._iid),a=Date.now(),i=this._generateRequestId();e.sleep(2).then((()=>{const n=this._createPendingScheduledUserMessage(s,i,a);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return t._trigger(n)}))))}));const r=new Ce(Object.assign({reqId:i,channelType:this.channelType,channelUrl:this.url},s));n.send(r).then((s=>{const{message:n}=s.as(Se);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return t._trigger(n)}))))})).catch((n=>{if(e.isThrowingOutside(n))throw n;e.sleep(2).then((()=>{const r=this._createPendingScheduledUserMessage(s,i,a);this._markMessageAsFailed(r,n),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return t._trigger(r)}))))}))}))}sendFileMessage(s){const t=Object.assign(Object.assign({},d),s);return e.unless(l(t)).throw(e.SendbirdError.invalidParameters),this._sendFileMessage(t)}sendMultipleFilesMessage(s){var t;const n=Object.assign(Object.assign({},u),s),i=e.Vault.of(this._iid);e.unless(((s,t=e.DEFAULT_MULTIPLE_FILES_MESSAGE_FILE_COUNT_LIMIT)=>a(s)&&Array.isArray(s.fileInfoList)&&s.fileInfoList.length>=2&&s.fileInfoList.length<=t&&s.fileInfoList.every((e=>c(e))))(n,null===(t=i.appInfo)||void 0===t?void 0:t.multipleFilesMessageFileCountLimit)).throw(e.SendbirdError.invalidParameters);const r=!!s.fileInfoList.find((e=>{const s=i.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>s||e.fileSize>s}));return e.unless(!r).throw(e.SendbirdError.fileSizeLimitExceededError),this._sendMultipleFilesMessage(n)}_sendFileMessage(t,n,a=!1){const{dispatcher:i,sessionManager:r}=e.Vault.of(this._iid),{fileMessageQueue:o}=s.MessageManager.of(this._iid);let d=null!=n?n:this._generateRequestId();const l=Date.now(),u=new s.MessageRequestHandler;return d||(d=this._generateRequestId()),e.sleep(2).then((()=>{const s=this._createPendingFileMessage(t,d,l);i.dispatch(new e.MessageUpdateEventCommand({messages:[s],source:a?e.MessageEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return u._trigger(s)})))),o.request(this,d,t).then((s=>{i.dispatch(new e.MessageUpdateEventCommand({messages:[s],source:e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return u._trigger(s)}))))})).catch((s=>{if(e.isThrowingOutside(s))throw s;e.sleep(2).then((()=>{const n=this._createPendingFileMessage(t,d,l),{cacheContext:a}=e.Vault.of(this._iid),r=a.localCacheEnabled&&e.isAutoResendableError(s.code);this._markMessageAsFailed(n,s,r),i.dispatch(new e.MessageUpdateEventCommand({messages:[n],source:n.sendingStatus===e.SendingStatus.PENDING?e.MessageEventSource.REQUEST_RESEND_MESSAGE:s.code===e.SendbirdErrorCode.FILE_UPLOAD_CANCEL_FAILED?e.MessageEventSource.LOCAL_MESSAGE_CANCELED:e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return u._triggerFailed(s,n)}))))}))}))})),u}_autoResendFileMessage(t){e.unless(t instanceof s.FileMessage&&!!t.messageParams).throw(e.SendbirdError.invalidParameters);const{logger:n}=e.Vault.of(this._iid);return n.debug("autoResendFileMessage pending",t),this._sendFileMessage(t.messageParams,t.reqId).onFailed((e=>{n.debug("autoResendFileMessage failed",e)})).onSucceeded((e=>{n.debug("autoResendFileMessage success",e)}))}_sendMultipleFilesMessage(t,n){const{dispatcher:a,sessionManager:i}=e.Vault.of(this._iid),{fileMessageQueue:r}=s.MessageManager.of(this._iid);let o=null!=n?n:this._generateRequestId();const d=Date.now(),l=new s.MultipleFilesMessageRequestHandler;return o||(o=this._generateRequestId()),e.sleep(2).then((()=>{const s=this._createPendingMultipleFilesMessage(t,o,d);a.dispatch(new e.MessageUpdateEventCommand({messages:[s],source:e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return l._trigger(s)})))),r.request(this,o,t,l).then((s=>{a.dispatch(new e.MessageUpdateEventCommand({messages:[s],source:e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return l._trigger(s)}))))})).catch((s=>{if(e.isThrowingOutside(s))throw s;e.sleep(2).then((()=>{const n=this._createPendingMultipleFilesMessage(t,o,d);this._markMessageAsFailed(n,s),a.dispatch(new e.MessageUpdateEventCommand({messages:[n],source:e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return l._triggerFailed(s,n)}))))}))}))})),l}_createScheduledFileMessage(s,t,n,a){const{requestQueue:i}=e.Vault.of(this._iid),r=new Oe(Object.assign(Object.assign({reqId:n,channelType:this.channelType,channelUrl:this.url},s),{fileUrl:s.fileUrl,requireAuth:s.requireAuth}));i.send(r).then((s=>{const{message:n}=s.as(we);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return t._trigger(n)}))))})).catch((i=>{if(e.isThrowingOutside(i))throw i;e.sleep(2).then((()=>{const r=this._createPendingScheduledFileMessage(s,n,a);this._markMessageAsFailed(r,i),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){return t._triggerFailed(i,r)}))))}))}))}sendFileMessages(t){e.unless(t.every((e=>l(Object.assign(Object.assign({},d),e))))).throw(e.SendbirdError.invalidParameters);const n=new s.MessageRequestHandler;for(const e of t)this.sendFileMessage(e).onPending((e=>n._trigger(e))).onFailed(((e,s)=>n._triggerFailed(e,s))).onSucceeded((e=>n._trigger(e)));return n}resendFileMessage(t,n){var a;return e.__awaiter(this,void 0,void 0,(function*(){const i=Boolean(t.url)||e.isFile(n)||e.isFile(null===(a=t.messageParams)||void 0===a?void 0:a.file);e.unless(t instanceof s.FileMessage&&i&&!t.scheduledInfo).throw(e.SendbirdError.invalidParameters);const r=new e.Deferred,o=((s,t)=>{var n;return s.messageParams?(!s.url&&e.isFile(t)&&(s.messageParams.file=t),s.messageParams):e.deundefined(e.undefineNullProps({data:s.data,customType:s.customType,mentionType:s.mentionType,mentionedUsers:s.mentionedUsers,mentionedUserIds:s.mentionedUserIds,metaArrays:s.metaArrays,parentMessageId:s.parentMessageId,appleCriticalAlertOptions:s.appleCriticalAlertOptions,file:t,fileUrl:s.url,fileName:s.name,fileSize:s.size,mimeType:s.type,thumbnailSizes:null===(n=s.thumbnails)||void 0===n?void 0:n.map((e=>({maxWidth:e.width,maxHeight:e.height})))}))})(t,n);return this._sendFileMessage(o,t.reqId,!0).onFailed((e=>r.reject(e))).onSucceeded((e=>r.resolve(e))),r.promise}))}updateFileMessage(s,t){return e.__awaiter(this,void 0,void 0,(function*(){const n=Object.assign(Object.assign({},v),t);e.unless(e.isTypeOf("number",s)&&(e=>y(e))(n)).throw(e.SendbirdError.invalidParameters);const{requestQueue:a}=e.Vault.of(this._iid),i=new _e(Object.assign({channelType:this.channelType,channelUrl:this.url,messageId:s},n)),r=yield a.send(i),{message:o}=r.as(fe);return o}))}cancelUploadingFileMessage(t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);const{fileMessageQueue:n}=s.MessageManager.of(this._iid);return n.cancel(this,t),!0}))}copyFileMessage(t,n){var a,i,r;return e.__awaiter(this,void 0,void 0,(function*(){e.unless(t instanceof Be&&n instanceof s.FileMessage&&n.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===n.channelUrl&&!n.scheduledInfo).throw(e.SendbirdError.invalidParameters);const o=new e.Deferred,d=e.undefineNullProps(Object.assign(Object.assign({},n),{fileUrl:n.url,fileName:n.name,fileSize:n.size,mimeType:n.type,mentionType:n.mentionType,mentionedUserIds:null!==(a=n.mentionedUserIds)&&void 0!==a?a:null===(i=n.mentionedUsers)||void 0===i?void 0:i.map((e=>e.userId)),pushNotificationDeliveryOption:e.PushNotificationDeliveryOption.DEFAULT,parentMessageId:null,isReplyToChannel:!1,thumbnailSizes:null===(r=n.thumbnails)||void 0===r?void 0:r.map((e=>({maxWidth:e.width,maxHeight:e.height}))),requireAuth:n.requireAuth,isPinnedMessage:!1}));return t._sendFileMessage(d).onSucceeded((e=>o.resolve(e))).onFailed((e=>o.reject(e))),o.promise}))}deleteMessage(t){return e.__awaiter(this,void 0,void 0,(function*(){if(e.unless(t instanceof s.BaseMessage).throw(e.SendbirdError.invalidParameters),t.messageId>0){const{requestQueue:s}=e.Vault.of(this._iid),n=new ve({channelType:this.channelType,channelUrl:this.url,messageId:t.messageId});yield s.send(n)}}))}addReaction(t,n){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(t instanceof s.BaseMessage&&t.messageId>0&&e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters);const{requestQueue:a}=e.Vault.of(this._iid),i=new Me({channelType:this.channelType,channelUrl:this.url,messageId:t.messageId,reactionKey:n}),r=yield a.send(i),{reactionEvent:o}=r.as(Ie);return o}))}deleteReaction(t,n){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(t instanceof s.BaseMessage&&t.messageId>0&&e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters);const{requestQueue:a}=e.Vault.of(this._iid),i=new Ee({channelType:this.channelType,channelUrl:this.url,messageId:t.messageId,reactionKey:n}),r=yield a.send(i),{reactionEvent:o}=r.as(Ae);return o}))}_updateUserMessageMetaArray(s,t,n,a){return e.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:i,requestQueue:r}=e.Vault.of(this._iid),o=new ge({channelType:this.channelType,channelUrl:this.url,messageId:s,metaArrayParams:{array:t,mode:n,upsert:a}}),d=yield r.send(o),{message:l}=d.as(ye);return i.dispatch(new e.MessageUpdateEventCommand({messages:[l],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),l}))}_updateFileMessageMetaArray(s,t,n,a){return e.__awaiter(this,void 0,void 0,(function*(){const{dispatcher:i,requestQueue:r}=e.Vault.of(this._iid),o=new _e({channelType:this.channelType,channelUrl:this.url,messageId:s,metaArrayParams:{array:t,mode:n,upsert:a}}),d=yield r.send(o),{message:l}=d.as(fe);return i.dispatch(new e.MessageUpdateEventCommand({messages:[l],source:e.MessageEventSource.EVENT_MESSAGE_UPDATED})),l}))}createMessageMetaArrayKeys(t,n){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(t instanceof s.BaseMessage&&t.messageId>0&&e.isArrayOf("string",n)).throw(e.SendbirdError.invalidParameters);const a=n.map((e=>new s.MessageMetaArray({key:e})));return t instanceof s.FileMessage?this._updateFileMessageMetaArray(t.messageId,a,"add",!0):this._updateUserMessageMetaArray(t.messageId,a,"add",!0)}))}deleteMessageMetaArrayKeys(t,n){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(t instanceof s.BaseMessage&&t.messageId>0&&e.isArrayOf("string",n)).throw(e.SendbirdError.invalidParameters);const a=n.map((e=>new s.MessageMetaArray({key:e})));return t instanceof s.FileMessage?this._updateFileMessageMetaArray(t.messageId,a,"remove",!0):this._updateUserMessageMetaArray(t.messageId,a,"remove",!0)}))}addMessageMetaArrayValues(t,n){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(t instanceof s.BaseMessage&&t.messageId>0&&n.every((e=>e instanceof s.MessageMetaArray))).throw(e.SendbirdError.invalidParameters),t instanceof s.FileMessage?this._updateFileMessageMetaArray(t.messageId,n,"add",!0):this._updateUserMessageMetaArray(t.messageId,n,"add",!0)}))}removeMessageMetaArrayValues(t,n){return e.__awaiter(this,void 0,void 0,(function*(){return e.unless(t instanceof s.BaseMessage&&t.messageId>0&&n.every((e=>e instanceof s.MessageMetaArray))).throw(e.SendbirdError.invalidParameters),t instanceof s.FileMessage?this._updateFileMessageMetaArray(t.messageId,n,"remove",!0):this._updateUserMessageMetaArray(t.messageId,n,"remove",!0)}))}report(s,t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isEnumOf(exports.ReportCategory,s)&&e.isTypeOf("string",t)).throw(e.SendbirdError.invalidParameters);const{sdkState:n,requestQueue:a}=e.Vault.of(this._iid),i=new ue({channelUrl:this.url,channelType:this.channelType,userId:n.userId,category:s,description:t});yield a.send(i)}))}reportUser(s,t,n){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(s instanceof e.User&&e.isEnumOf(exports.ReportCategory,t)&&e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters);const{sdkState:a,requestQueue:i}=e.Vault.of(this._iid),r=new ce({channelUrl:this.url,channelType:this.channelType,userId:a.userId,offendingUserId:s.userId,category:t,description:n});yield i.send(r)}))}reportMessage(t,n,a){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(t instanceof s.SendableMessage&&e.isEnumOf(exports.ReportCategory,n)&&e.isTypeOf("string",a)).throw(e.SendbirdError.invalidParameters);const{sdkState:i,requestQueue:r}=e.Vault.of(this._iid),o=new he({channelUrl:this.url,channelType:this.channelType,userId:i.userId,offendingUserId:t.sender.userId,messageId:t.messageId,category:n,description:a});yield r.send(o)}))}updatePoll(s,t){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("number",s)&&(s=>e.isTypeOf("string",s.title,!0)&&e.validatePollData(s.data)&&e.isTypeOf("boolean",s.allowUserSuggestion,!0)&&e.isTypeOf("boolean",s.allowMultipleVotes,!0)&&e.isTypeOf("number",s.closeAt,!0))(t)).throw(e.SendbirdError.invalidParameters);const{requestQueue:n}=e.Vault.of(this._iid),a=new be(Object.assign({pollId:s},t)),i=yield n.send(a),{poll:r}=i.as(Re);return r}))}deletePoll(s){return e.__awaiter(this,void 0,void 0,(function*(){const t=e.isTypeOf("number",s);e.unless(t).throw(e.SendbirdError.invalidParameters);const{requestQueue:n}=e.Vault.of(this._iid),a=new qe({pollId:s});yield n.send(a)}))}closePoll(s){return e.__awaiter(this,void 0,void 0,(function*(){const t=e.isTypeOf("number",s);e.unless(t).throw(e.SendbirdError.invalidParameters);const{requestQueue:n}=e.Vault.of(this._iid),a=new xe({pollId:s}),i=yield n.send(a),{poll:r}=i.as(Le);return r}))}addPollOption(s,t){return e.__awaiter(this,void 0,void 0,(function*(){const n=e.isTypeOf("number",s)&&e.isTypeOf("string",t)&&""!==t.trim();e.unless(n).throw(e.SendbirdError.invalidParameters);const{requestQueue:a}=e.Vault.of(this._iid),i=new De({channelUrl:this.url,channelType:this.channelType,pollId:s,optionText:t}),r=yield a.send(i),{poll:o}=r.as(Ne);return o}))}updatePollOption(s,t,n){return e.__awaiter(this,void 0,void 0,(function*(){const a=e.isTypeOf("number",s)&&e.isTypeOf("number",t)&&e.isTypeOf("string",n)&&""!==n.trim();e.unless(a).throw(e.SendbirdError.invalidParameters);const{requestQueue:i}=e.Vault.of(this._iid),r=new Fe({pollId:s,pollOptionId:t,optionText:n}),o=yield i.send(r),{poll:d}=o.as(ke);return d}))}deletePollOption(s,t){return e.__awaiter(this,void 0,void 0,(function*(){const n=e.isTypeOf("number",s)&&e.isTypeOf("number",t);e.unless(n).throw(e.SendbirdError.invalidParameters);const{requestQueue:a}=e.Vault.of(this._iid),i=new Ve({pollId:s,pollOptionId:t});yield a.send(i)}))}votePoll(s,t){return e.__awaiter(this,void 0,void 0,(function*(){const n=e.isTypeOf("number",s)&&e.isArrayOf("number",t);e.unless(n).throw(e.SendbirdError.invalidParameters);const{requestQueue:a,dispatcher:i}=e.Vault.of(this._iid),r=new $e({reqId:this._generateRequestId(),channelUrl:this.url,channelType:this.channelType,pollId:s,pollOptionIds:t}),o=yield a.send(r),{event:d}=o.as(je);return i.dispatch(new e.PollVoteInternalEventCommand({event:d,source:e.MessageEventSource.EVENT_POLL_VOTED})),d}))}getPollChangeLogsSinceTimestamp(s){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("number",s)).throw(e.SendbirdError.invalidParameters);const n=t.PollManager.of(this._iid);return yield n.getPollChangeLogs(this.url,this.channelType,s)}))}getPollChangeLogsSinceToken(s){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",s,!0));const n=t.PollManager.of(this._iid);return yield n.getPollChangeLogs(this.url,this.channelType,s)}))}createPollListQuery(e=10){return new t.PollListQuery(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})}createPollVoterListQuery(e,s,n=20){return new t.PollVoterListQuery(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:s,limit:n})}}exports.BanUserEventCommand=ie,exports.BannedUserListQuery=S,exports.BaseChannel=Be,exports.BaseMessageCreateParamsDefault=n,exports.BaseMessageUpdateParamsDefault=g,exports.CreateScheduledUserMessageResponseCommand=Se,exports.DEFAULT_GROUPCHANNEL_LIMIT=100,exports.DEFAULT_MESSAGE_LIMIT=100,exports.DeleteMessageEventCommand=Te,exports.FreezeEventCommand=le,exports.MuteUserEventCommand=se,exports.MutedUserListQuery=P,exports.NESTDB_GROUPCHANNEL_COLLECTION_KEY="url",exports.NESTDB_GROUPCHANNEL_COLLECTION_NAME="GroupChannel",exports.NESTDB_MESSAGE_COLLECTION_KEY="messageId",exports.NESTDB_MESSAGE_COLLECTION_NAME="Message",exports.NESTDB_POLL_COLLECTION_KEY="pollId",exports.NESTDB_POLL_COLLECTION_NAME="Poll",exports.OperatorListQuery=I,exports.PENDING_MESSAGE_DELAY=2,exports.PollVoteEventCommand=je,exports.RestrictedUser=m,exports.RestrictionInfo=p,exports.UnbanUserEventCommand=oe,exports.UnmuteUserEventCommand=ne,exports.UpdateFileMessageEventCommand=fe,exports.UpdateMetaCounterEventCommand=J,exports.UpdateMetaDataEventCommand=V,exports.UpdateUserMessageEventCommand=ye,exports.UserMessageCreateParamsDefault=i,exports.UserMessageEventCommand=me,exports.UserMessageUpdateParamsDefault=_,exports.isBlobInstance=e=>"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob,exports.isFileTypeBlob=e=>e===exports.FileType.BLOB||e===exports.FileType.FILE,exports.serializeFileMessageCreateParams=e=>({file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}),exports.serializeMultipleFilesMessageCreateParams=s=>e.deundefined({fileInfoList:s.fileInfoList,isReplyToChannel:s.isReplyToChannel,pushNotificationDeliveryOption:s.pushNotificationDeliveryOption}),exports.serializeUserMessageCreateParams=e=>({isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}),exports.validateBaseMessageCreateParams=a,exports.validateBaseMessageUpdateParams=y,exports.validateUserMessageCreateParams=r,exports.validateUserMessageUpdateParams=f; diff --git a/cjs/lib/__bundle-aba6d9af.js b/cjs/lib/__bundle-aba6d9af.js new file mode 100644 index 0000000..7920641 --- /dev/null +++ b/cjs/lib/__bundle-aba6d9af.js @@ -0,0 +1 @@ +"use strict";var e,n=require("./__bundle-032c97c6.js"),t=require("./__bundle-7e34e7ed.js"),o=require("./__bundle-481ecf03.js");exports.ChannelEventCategory=void 0,(e=exports.ChannelEventCategory||(exports.ChannelEventCategory={}))[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";class s{constructor(e){var n;this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=null!==(n=e.data)&&void 0!==n?n:{},this.ts=e.ts}get isGroupChannelEvent(){return this.channelType===n.ChannelType.GROUP}get isOpenChannelEvent(){return this.channelType===n.ChannelType.OPEN}}class a extends n.WebSocketEventCommand{constructor(e,n,t){super(e,"SYEV",t),this.event=new s(t)}}class E extends n.WebSocketEventCommand{constructor(e,n,t){super(e,"MCNT",t),this.groupChannelMemberCounts=t.group_channels.map((e=>({channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}))),this.openChannelMemberCounts=t.open_channels.map((e=>({channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts})))}}class N extends n.WebSocketEventCommand{constructor(e,o,s){var a,E,N,r;super(e,"ADMM",s),this.message=new t.AdminMessage(e,s);const{sdkState:d}=n.Vault.of(e);this.isMentioned=n.checkIfMentioned(this.message.mentionType,null!==(N=null!==(a=this.message.mentionedUserIds)&&void 0!==a?a:null===(E=this.message.mentionedUsers)||void 0===E?void 0:E.map((e=>e.userId)))&&void 0!==N?N:[],d.userId),this.forceUpdateLastMessage=null!==(r=s.force_update_last_message)&&void 0!==r&&r}}class r extends n.WebSocketEventCommand{constructor(e,o,s){var a,E,N,r,d;super(e,"AEDI",s),this.message=new t.AdminMessage(e,s);const{sdkState:i}=n.Vault.of(e);this.mentionCountChange=n.calculateMentionCountChange({mentionType:null===(a=s.old_values)||void 0===a?void 0:a.mention_type,mentionedUserIds:null!==(N=null===(E=s.old_values)||void 0===E?void 0:E.mentioned_user_ids)&&void 0!==N?N:[]},n.undefineNullProps({mentionType:this.message.mentionType,mentionedUserIds:null!==(r=this.message.mentionedUserIds)&&void 0!==r?r:null===(d=this.message.mentionedUsers)||void 0===d?void 0:d.map((e=>e.userId))}),i.userId)}}class d extends n.WebSocketEventCommand{constructor(e,n,o){super(e,"MRCT",o),this.channelUrl=o.channel_url,this.channelType=o.channel_type,this.event=new t.ReactionEvent(o)}}class i extends n.WebSocketEventCommand{constructor(e,n,o){super(e,"MTHD",o),this.event=new t.ThreadInfoUpdateEvent(e,o)}}class C extends n.WebSocketEventCommand{constructor(e,t,s){super(e,"PEDI",s),this.event=new o.PollUpdateEvent(e,s),this.status=n.parsePollStatusPayload(s.poll.status)||s.poll.status,this.channelUrl=s.channel_url,this.channelType=s.channel_type}}exports.AdminMessageEventCommand=N,exports.BaseChannelHandlerParams=class{constructor(){this.onUserMuted=n.noop,this.onUserUnmuted=n.noop,this.onUserBanned=n.noop,this.onUserUnbanned=n.noop,this.onChannelChanged=n.noop,this.onChannelDeleted=n.noop,this.onChannelFrozen=n.noop,this.onChannelUnfrozen=n.noop,this.onOperatorUpdated=n.noop,this.onChannelMemberCountChanged=n.noop,this.onMetaDataCreated=n.noop,this.onMetaDataUpdated=n.noop,this.onMetaDataDeleted=n.noop,this.onMetaCounterCreated=n.noop,this.onMetaCounterUpdated=n.noop,this.onMetaCounterDeleted=n.noop,this.onMessageReceived=n.noop,this.onMessageUpdated=n.noop,this.onMessageDeleted=n.noop,this.onMentionReceived=n.noop,this.onReactionUpdated=n.noop,this.onThreadInfoUpdated=n.noop}},exports.ChannelEventCommand=a,exports.MemberCountUpdateEventCommand=E,exports.OperatorUpdateEventCommand=class extends a{constructor(e,t,o){super(e,t,o);const{operators:s=[]}=o.data;this.operators=s.map((e=>new n.User(this._iid,e)))}},exports.PollUpdateEventCommand=C,exports.ReactionEventCommand=d,exports.ThreadInfoUpdateEventCommand=i,exports.UpdateAdminMessageEventCommand=r; diff --git a/cjs/lib/__bundle-c8f25be2.js b/cjs/lib/__bundle-c8f25be2.js new file mode 100644 index 0000000..a3842aa --- /dev/null +++ b/cjs/lib/__bundle-c8f25be2.js @@ -0,0 +1 @@ +"use strict";var e,t,i,s=require("./__bundle-032c97c6.js"),r=require("./__bundle-aa0921e3.js"),n=require("./__bundle-7e34e7ed.js");exports.GroupChannelListOrder=void 0,(e=exports.GroupChannelListOrder||(exports.GroupChannelListOrder={})).LATEST_LAST_MESSAGE="latest_last_message",e.CHRONOLOGICAL="chronological",e.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",e.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",exports.PublicGroupChannelListOrder=void 0,(t=exports.PublicGroupChannelListOrder||(exports.PublicGroupChannelListOrder={})).CHRONOLOGICAL="chronological",t.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",t.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",exports.ScheduledMessageListOrder=void 0,(i=exports.ScheduledMessageListOrder||(exports.ScheduledMessageListOrder={})).CREATED_AT="created_at",i.SCHEDULED_AT="scheduled_at";class a{constructor(){this.messageTypeFilter=s.MessageTypeFilter.ALL,this.customTypesFilter=null,this.senderUserIdsFilter=null,this.replyType=s.ReplyType.NONE}clone(){const e=new a,t=JSON.parse(JSON.stringify(this));return Object.keys(t).forEach((i=>{e[i]=t[i]})),e}match(e){switch(this.messageTypeFilter){case s.MessageTypeFilter.USER:if(e.messageType!==s.MessageType.USER)return!1;break;case s.MessageTypeFilter.FILE:if(e.messageType!==s.MessageType.FILE)return!1;break;case s.MessageTypeFilter.ADMIN:if(e.messageType!==s.MessageType.ADMIN)return!1}if(this.customTypesFilter&&this.customTypesFilter.length>0&&!this.customTypesFilter.includes(e.customType))return!1;if(this.senderUserIdsFilter&&this.senderUserIdsFilter.length>0){if(!(e instanceof n.SendableMessage))return!1;if(!this.senderUserIdsFilter.includes(e.sender.userId))return!1}switch(this.replyType){case s.ReplyType.NONE:if(e.parentMessageId>0)return!1;break;case s.ReplyType.ONLY_REPLY_TO_CHANNEL:if(e instanceof n.SendableMessage&&e.parentMessageId>0&&!e.replyToChannel)return!1}return!0}}var o;exports.MessageListOrder=void 0,(o=exports.MessageListOrder||(exports.MessageListOrder={})).CHANNEL_LATEST="channel_latest",o.NEWEST_CHILD_MESSAGE="newest_child_message";const l=e=>{switch(e){case exports.MessageListOrder.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case exports.MessageListOrder.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},d=()=>"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product,c=()=>{let e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(t=>{const i=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?i:3&i|8).toString(16)}))};var h,_;!function(e){e[e.PROCESSING=0]="PROCESSING",e[e.DONE=1]="DONE"}(h||(h={})),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"}(_||(_={}));const u={};class E{constructor(e,t={}){return this._state=h.PROCESSING,this._queue=[],this._activationQueue=[],u[e]&&!t.forceCreate||(this.nodeId=c(),this.key=e,d()&&(t.startAsInvisible?this.registerNode():"visible"===document.visibilityState?this.claimHost():this.registerNode(),document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&this.claimHost()})),window.addEventListener("message",(e=>{const t=e.data,{nodeId:i,requestId:s,key:r,op:n,data:a}=t;if(i!==this.nodeId&&r===this.key)switch(n){case _.NEWNODE:this._sendSync();break;case _.CLAIM_HOST:this._sendSync(),this._hostId=i;break;case _.SYNC_HOST:if(!this.isInSync){this._activationTimeout&&clearTimeout(this._activationTimeout);const{currentItemRequestId:e,queue:t}=a;for(const e of t){this._queue.findIndex((t=>t.requestId===e.requestId))<0&&this._requestLock({nodeId:e.nodeId,requestId:e.requestId,key:this.key,op:_.REQUEST_LOCK,ts:e.ts})}this._currentItem=this._queue.find((t=>t.requestId===e)),this._completeSync()}break;case _.REMOVENODE:this._queue=this._queue.filter((e=>e.nodeId!==t.nodeId)),this._currentItem&&this._currentItem.nodeId===t.nodeId&&(this._currentItem=void 0,this._acquire(this._queue[0]));break;case _.REQUEST_LOCK:this._requestLock(t);break;case _.ACQUIRE_LOCK:{const e=this._queue.find((e=>e.requestId===s));this._acquire(e);break}case _.RELEASE_LOCK:this._release(s)}})),window.addEventListener("beforeunload",(()=>{this._send(_.REMOVENODE)}))),u[e]=this),u[e]}get locked(){return!!this._currentItem}get isHost(){return this._hostId===this.nodeId}get isInSync(){return this._state==h.DONE}_send(e,t={}){var i;const s={nodeId:this.nodeId,requestId:null!==(i=null==t?void 0:t.requestId)&&void 0!==i?i:c(),key:this.key,op:e,data:t.data,ts:Date.now()};return d()&&window.postMessage(s,"*"),s}_acquire(e){e?(this._currentItem=e,this._currentItem.onAcquired&&this._currentItem.onAcquired(e.requestId)):this._currentItem=void 0}_release(e){if(this._currentItem&&this._currentItem.requestId===e){const t=this._currentItem;this._currentItem=void 0,t.nodeId===this.nodeId&&this._send(_.RELEASE_LOCK,{requestId:t.requestId});const i=this._queue.findIndex((t=>t.requestId===e));i>-1&&this._queue.splice(i,1),t.onReleased&&t.onReleased(e)}}_requestLock(e){return new Promise((t=>{const i={nodeId:e.nodeId,requestId:e.requestId,ts:e.ts,onAcquired:e=>{this.isHost&&this._send(_.ACQUIRE_LOCK,{requestId:e}),t()},onReleased:()=>{this._acquire(this._queue[0])}};let s=!1;for(const e in this._queue)if(this._queue[e].ts>i.ts){this._queue.splice(parseInt(e),0,i),s=!0;break}s||this._queue.push(i),this._currentItem||this._acquire(this._queue[0])}))}_sendSync(){var e;this.isHost&&this._send(_.SYNC_HOST,{data:{currentItemRequestId:null===(e=this._currentItem)||void 0===e?void 0:e.requestId,queue:this._queue.map((e=>({nodeId:e.nodeId,requestId:e.requestId,ts:e.ts})))}})}_waitUntilSyncCompleted(){return s.__awaiter(this,void 0,void 0,(function*(){if(this.isHost&&!this.isInSync)return new Promise((e=>{this._activationQueue.push(e)}))}))}_waitSync(){this.isInSync||(this._activationTimeout=setTimeout((()=>{this._completeSync()}),8))}_completeSync(){this.isInSync||(this._state=h.DONE,this._activationQueue.forEach((e=>e())),this._activationQueue=[])}registerNode(){this._send(_.NEWNODE),this._waitSync()}claimHost(){this._hostId=this.nodeId,this._send(_.CLAIM_HOST),this._waitSync()}lock(){return s.__awaiter(this,void 0,void 0,(function*(){yield this._waitUntilSyncCompleted();const e=this._send(_.REQUEST_LOCK);yield this._requestLock(e)}))}unlock(){var e;(null===(e=this._currentItem)||void 0===e?void 0:e.requestId)&&this._release(this._currentItem.requestId)}}const m=Object.assign(Object.assign({},r.UserMessageCreateParamsDefault),{scheduledAt:void 0}),f=Object.assign(Object.assign({},r.BaseMessageCreateParamsDefault),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),g="UnsentMessage",y={};class N extends s.InstancedObject{constructor(e,{sdkState:t,cacheContext:i}){super(e),this._sdkState=t,this._cacheContext=i,y[e]=this,this._mutex=new E("unsendmessagecache.lock")}static of(e){return y[e]}get collection(){const{nestdb:e}=this._cacheContext,t=null==e?void 0:e.collection(g);if(!t)throw s.SendbirdError.databaseError;return t}get localCacheEnabled(){const{localCacheEnabled:e}=this._cacheContext;return e&&!!this.collection}_serialize(e){if(e.messageId>0)throw s.SendbirdError.invalidParameters;const t=Object.assign({},e.serialize());var i;return e instanceof n.UserMessage?(e.messageParams&&(t.messageParams=r.serializeUserMessageCreateParams(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(t.scheduledInfo.scheduledMessageParams=(i=e.scheduledInfo.scheduledMessageParams,Object.assign(Object.assign({},r.serializeUserMessageCreateParams(i)),{scheduledAt:i.scheduledAt})))):e instanceof n.FileMessage?(e.messageParams&&(t.messageParams=r.serializeFileMessageCreateParams(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(t.scheduledInfo.scheduledMessageParams=(e=>Object.assign(Object.assign({},r.serializeFileMessageCreateParams(e)),{scheduledAt:e.scheduledAt}))(e.scheduledInfo.scheduledMessageParams))):e instanceof n.MultipleFilesMessage&&e.messageParams&&(t.messageParams=r.serializeMultipleFilesMessageCreateParams(e.messageParams)),t}_deserialize(e){e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)});return n.MessageManager.of(this._iid).buildMessageFromSerializedData(e)}_deserializeWithMessageCreateParams(e){var t,i,a;return s.__awaiter(this,void 0,void 0,(function*(){const o=n.MessageManager.of(this._iid),l=this._deserialize(e);if(e.messageParams)if(l instanceof n.UserMessage){const t=e.messageParams;l.messageParams=o.buildUserMessageCreateParamsFromSerializedData(t,l)}else if(l instanceof n.FileMessage){const s=e.messageParams;s.fileKey&&"string"==typeof s.fileKey&&r.isFileTypeBlob(null!==(t=s.fileType)&&void 0!==t?t:"")&&(s.file=null!==(i=yield this.collection.getBlob(s.fileKey))&&void 0!==i?i:void 0),l.messageParams=o.buildFileMessageCreateParamsFromSerializedData(s,l)}else if(l instanceof n.MultipleFilesMessage){const t=e.messageParams;t&&t.fileInfoList&&(l.messageParams=o.buildMultipleFilesMessageCreateParamsFromSerializedData(t,l),yield Promise.all(l.messageParams.fileInfoList.map((e=>s.__awaiter(this,void 0,void 0,(function*(){var t,i,s,n;"string"==typeof(null===(t=e._uploadedMetaData)||void 0===t?void 0:t.fileKey)&&r.isFileTypeBlob(null!==(s=null===(i=e._uploadedMetaData)||void 0===i?void 0:i.fileType)&&void 0!==s?s:"")&&(e.file=null!==(n=yield this.collection.getBlob(e._uploadedMetaData.fileKey))&&void 0!==n?n:void 0)}))))))}if(l.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams)if(l instanceof n.UserMessage){const t=e.scheduledInfo.scheduledMessageParams;l.scheduledInfo.scheduledMessageParams=o.buildScheduledUserMessageCreateParamsFromSerializedData(t,l)}else if(l instanceof n.FileMessage){const t=e.scheduledInfo.scheduledMessageParams;t.fileKey&&"string"==typeof t.fileKey&&"string"==typeof t.fileType&&r.isFileTypeBlob(t.fileType)&&(t.file=null!==(a=yield this.collection.getBlob(t.fileKey))&&void 0!==a?a:void 0),l.scheduledInfo.scheduledMessageParams=o.buildScheduledFileMessageCreateParamsFromSerializedData(t,l)}return l}))}_getFileInfoBlobKey(e,t){return`${e}.${t}`}get(e){return s.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t=yield this.collection.getByKey(`${e}`);if(t)return this._deserializeWithMessageCreateParams(t)}}))}fetch({channelUrl:e,filter:t=new a,order:i=exports.MessageListOrder.CHANNEL_LATEST,sendingStatus:r,backward:n=!1,parentMessageId:o}){return s.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const a=l(i),d={"/where":e=>!!(i!==exports.MessageListOrder.NEWEST_CHILD_MESSAGE||o&&0!==e.parentMessageId&&e.parentMessageId===o)&&t.match(this._deserialize(e))};e&&(d.channelUrl=e),r&&(d.sendingStatus=r);const c={where:d,index:a,backward:n},h=yield this.collection.query(c),_=yield h.fetch({});return Promise.all(_.map((e=>s.__awaiter(this,void 0,void 0,(function*(){return yield this._deserializeWithMessageCreateParams(e)})))))}return[]}))}getAllChildMessages(e,t=new a){return s.__awaiter(this,void 0,void 0,(function*(){return yield this.fetch({filter:t,order:exports.MessageListOrder.NEWEST_CHILD_MESSAGE,channelUrl:e.channelUrl,backward:!1,parentMessageId:e.messageId})}))}upsert(e){return s.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield Promise.all(e.map((e=>s.__awaiter(this,void 0,void 0,(function*(){(e instanceof n.FileMessage||e instanceof n.MultipleFilesMessage)&&(yield this._mutex.lock(),yield this.saveBlob(e),yield this._mutex.unlock());const t=this._serialize(e);yield this.collection.upsertOne(t)}))))))}))}upsertChildMessages(e){return s.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield Promise.all(e.map((e=>s.__awaiter(this,void 0,void 0,(function*(){let t=[];e.threadInfo&&e.threadInfo.replyCount>0&&(t=yield this.getAllChildMessages(e)),t.length>0&&(t.forEach((t=>t.applyParentMessage(e))),yield this.upsert(t))}))))))}))}remove(e){return s.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled)for(const t of e)yield this.collection.remove(t)}))}removeMessagesOfChannel(e){return s.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.removeIf({where:{channelUrl:e}}))}))}clear(){return s.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.clear())}))}saveBlob(e){return s.__awaiter(this,void 0,void 0,(function*(){if(e instanceof n.FileMessage){if(e.messageParams){const t=e.messageParams;if(t.file&&r.isBlobInstance(t.file)){const i=yield this.collection.saveBlob(t.file,e.reqId);t.fileKey=i,t.fileType=r.FileType.BLOB}}if(e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams){const t=e.scheduledInfo.scheduledMessageParams;if(t.file&&r.isBlobInstance(t.file)){const i=yield this.collection.saveBlob(t.file,e.reqId);t.fileKey=i,t.fileType=r.FileType.BLOB}}}else if(e instanceof n.MultipleFilesMessage){const t=e.messageParams;t&&t.fileInfoList&&Array.isArray(t.fileInfoList)&&(yield Promise.all(t.fileInfoList.map(((t,i)=>s.__awaiter(this,void 0,void 0,(function*(){if(t.file&&r.isBlobInstance(t.file)){const s=yield this.collection.saveBlob(t.file,this._getFileInfoBlobKey(e.reqId,i));t._uploadedMetaData||(t._uploadedMetaData={}),t._uploadedMetaData.fileKey=s,t._uploadedMetaData.fileType=r.FileType.BLOB}}))))))}}))}}const v={};class I extends s.InstancedObject{constructor(e,{sdkState:t,cacheContext:i,unsentMessageCache:s}){super(e),this._sdkState=t,this._cacheContext=i,this._unsentMessageCache=s,v[e]=this}static of(e){return v[e]}get collection(){const{nestdb:e}=this._cacheContext;return s.unless(!!e).throw(s.SendbirdError.databaseError),e.collection(r.NESTDB_MESSAGE_COLLECTION_NAME)}get localCacheEnabled(){const{localCacheEnabled:e}=this._cacheContext;return e&&!!this.collection}_serialize(e){return Object.assign(Object.assign({},e.serialize()),{messageId:`${e.messageId}`})}_deserialize(e){e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)});return n.MessageManager.of(this._iid).buildMessageFromSerializedData(e)}get(e){return s.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const t=yield this.collection.getByKey(`${e}`);if(t)return this._deserialize(t)}}))}fetch({channelUrl:e,token:t,limit:i=r.DEFAULT_MESSAGE_LIMIT,filter:n=new a,order:o=exports.MessageListOrder.CHANNEL_LATEST,backward:d=!1,parentMessageId:c,isPollOnly:h=!1,exactMatch:_=!1,inclusive:u=!0}){return s.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const r=l(o),a={where:{channelUrl:e,"/where":e=>{if(t)switch(o){case exports.MessageListOrder.CHANNEL_LATEST:if(_&&e.createdAt!==t)return!1;if(d){if(u&&e.createdAtt||!u&&e.createdAt>=t)return!1;break;case exports.MessageListOrder.NEWEST_CHILD_MESSAGE:if(!c||0===e.parentMessageId||e.parentMessageId!==c)return!1}return!(h&&!e._poll)&&n.match(this._deserialize(e))}},index:r,backward:d},E=yield this.collection.query(a),m=yield E.fetch({limit:null!=i?i:void 0});return Promise.all(m.map((e=>s.__awaiter(this,void 0,void 0,(function*(){return this._deserialize(e)})))))}return[]}))}getAllChildMessages(e,t=new a){return s.__awaiter(this,void 0,void 0,(function*(){return yield this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:t,order:exports.MessageListOrder.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId})}))}upsert(e){return s.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){yield this.saveBlobs(e);const t=e.map((e=>this._serialize(e)));yield this.collection.upsertMany(t),yield this.upsertChildMessages(e),yield this._unsentMessageCache.upsertChildMessages(e)}}))}upsertChildMessages(e){return s.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield Promise.all(e.map((e=>s.__awaiter(this,void 0,void 0,(function*(){var t;let i=[];(null===(t=e.threadInfo)||void 0===t?void 0:t.replyCount)&&e.threadInfo.replyCount>0&&(i=yield this.getAllChildMessages(e)),i.length>0&&(i.forEach((t=>t.applyParentMessage(e))),yield this.upsert(i))}))))))}))}remove(e){return s.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled)for(const t of e)yield this.collection.remove(`${t}`)}))}removeMessagesOfChannel(e){return s.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){yield this.collection.removeIf({where:{channelUrl:e},index:l(exports.MessageListOrder.CHANNEL_LATEST)});const{preference:t}=this._cacheContext;yield t.remove(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/sync`),yield t.remove(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/sync.meta`),yield t.remove(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/changelogs`),yield t.remove(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/changelogs.meta`)}}))}removeUnderOffset(e,t){return s.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.removeIf({where:{channelUrl:e,createdAt:{"<":t}},index:l(exports.MessageListOrder.CHANNEL_LATEST)}))}))}clear(){return s.__awaiter(this,void 0,void 0,(function*(){this.localCacheEnabled&&(yield this.collection.clear())}))}countBetween(e,t,i){return s.__awaiter(this,void 0,void 0,(function*(){if(this.localCacheEnabled){const s=l(exports.MessageListOrder.CHANNEL_LATEST),r=this.collection.query({where:{channelUrl:e,"/where":e=>{const s=this._deserialize(e);return i.includes(s.createdAt)&&t.match(s)}},index:s});return yield r.count()}return 0}))}saveBlobs(e){return s.__awaiter(this,void 0,void 0,(function*(){yield Promise.all(e.map((e=>s.__awaiter(this,void 0,void 0,(function*(){if(e instanceof n.FileMessage&&e.messageParams){const t=e.messageParams;if(t.file&&r.isBlobInstance(t.file)){const i=yield this.collection.saveBlob(t.file,e.reqId);t.fileKey=i}}})))))}))}_getGroupChannelPreferenceSize(e){return s.__awaiter(this,void 0,void 0,(function*(){let t=0;const{preference:i}=this._cacheContext,s=yield i.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/sync`),r=yield i.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/sync.meta`),n=yield i.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/changelogs`),a=yield i.get(`sendbird:${this._sdkState.userId}@groupchannel/${e}/message/changelogs.meta`);return s&&(t+=JSON.stringify(s).length),r&&(t+=JSON.stringify(r).length),n&&(t+=JSON.stringify(n).length),a&&(t+=JSON.stringify(a).length),t}))}}class p extends s.BaseCommand{constructor({message:e}){super(),this.message=e}}const b={};var T,C;exports.UserEventCategory=void 0,(T=exports.UserEventCategory||(exports.UserEventCategory={}))[T.USER_BLOCK=20001]="USER_BLOCK",T[T.USER_UNBLOCK=2e4]="USER_UNBLOCK",T[T.FRIEND_DISCOVERED=20900]="FRIEND_DISCOVERED";class A{constructor(e){this.category=e.cat,this.data=e.data}static getDataAsUserBlockEvent(e,t){const{blocker:i,blockee:r}=t.data;return{blocker:new s.User(e,i),blockee:new s.User(e,r)}}static getDataAsFriendDiscoveredEvent(e,t){const{friend_discoveries:i}=t.data;return{friendDiscoveries:Array.isArray(i)?i.map((t=>new s.User(e,t))):[]}}}class O extends s.BaseCommand{constructor(e,{userId:t}){super(),this._iid=e,this.userId=t}}exports.GroupChannelEventSource=void 0,(C=exports.GroupChannelEventSource||(exports.GroupChannelEventSource={})).UNKNOWN="UNKNOWN",C.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",C.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",C.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",C.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",C.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",C.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",C.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",C.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",C.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",C.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",C.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",C.EVENT_CHANNEL_BANNED="EVENT_CHANNEL_BANNED",C.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",C.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",C.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",C.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",C.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",C.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",C.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",C.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",C.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",C.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",C.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",C.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",C.EVENT_PINNED_MESSAGE_UPDATED="EVENT_PINNED_MESSAGE_UPDATED",C.REQUEST_CHANNEL="REQUEST_CHANNEL",C.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",C.REFRESH_CHANNEL="REFRESH_CHANNEL",C.CHANNEL_LASTACCESSEDAT_UPDATED="CHANNEL_LASTACCESSEDAT_UPDATED",C.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",C.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS";class w extends s.BaseCommand{constructor({channels:e,source:t,isWebSocketEventComing:i=!1,data:s=null}){super(),this.channels=e,this.source=t,this.isWebSocketEventComing=i,this.data=s}}class S extends s.BaseCommand{constructor({channelUrls:e,source:t,isWebSocketEventComing:i=!1}){super(),this.channelUrls=e,this.source=t,this.isWebSocketEventComing=i}}class L extends s.BaseCommand{constructor(){super()}}class x extends s.WebSocketEventCommand{constructor(e,t,i){super(e,"USEV",i),this.event=new A(i)}}const k={};class R{constructor({dbname:e,itemSizeLimit:t=1048576,cacheLimit:i=256,blockHashBase:s=2,blockHashMultiplier:r=10,blockHashConstant:n=11,transactionApplyDelay:a=200,disableLogger:o=!1}){return k[e]||(this.itemSizeLimit=t,this.cacheLimit=i,this.blockHashBase=s,this.blockHashMultiplier=r,this.blockHashConstant=n,this.transactionApplyDelay=a,this.disableLogger=o,k[e]=this),k[e]}static get(e){return k[e]}}var M,D;!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"}(M||(M={}));class P extends Error{constructor({code:e=M.UNKNOWN_ERROR,message:t="Unknown error occurred."}){super(t),this.code=e,Object.setPrototypeOf(this,P.prototype)}static get storeNotDefined(){return new P({code:M.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})}static get storeNotAvailable(){return new P({code:M.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})}static get storeNotAvailableInPrivateBrowsing(){return new P({code:M.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING,message:"Store is not available because it is in private browsing."})}static get storeIsFull(){return new P({code:M.STORE_IS_FULL,message:"Store is full."})}static get storeNotInitialized(){return new P({code:M.STORE_NOT_INITIALIZED,message:"Store is not initialized."})}static get storeKeyTypeIsInvalid(){return new P({code:M.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})}static get storeBrokenIntegrity(){return new P({code:M.STORE_BROKEN_INTEGRITY,message:"Data should be in a store but it does not. Integrity is broken."})}static get storeBrokenBlob(){return new P({code:M.STORE_BROKEN_BLOB,message:"Data should be in a store but it does not. Blob data is broken."})}static get storeEncryptionInvalid(){return new P({code:M.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})}static get storeItemSizeExceeded(){return new P({code:M.STORE_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that the store allows."})}static get storeReadFailed(){return new P({code:M.STORE_READ_FAILED,message:"Failed to read from store."})}static get storeWriteFailed(){return new P({code:M.STORE_WRITE_FAILED,message:"Failed to write to store."})}static get databaseSchemaNotOnUpgrade(){return new P({code:M.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})}static get collectionNotReady(){return new P({code:M.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})}static get collectionKeyNotMatch(){return new P({code:M.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})}static get collectionQueryNotValid(){return new P({code:M.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})}static get collectionInsertDuplicate(){return new P({code:M.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})}static get collectionKeyNotFound(){return new P({code:M.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})}static get collectionKeyNotGiven(){return new P({code:M.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})}static get collectionWriteFailed(){return new P({code:M.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})}static get collectionItemSizeExceeded(){return new P({code:M.COLLECTION_ITEM_SIZE_LIMIT_EXCEEDED,message:"The size of the item exceeds the limit that a collection allows."})}static get indexTableIsRequired(){return new P({code:M.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})}static get indexTypesNotMatch(){return new P({code:M.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})}static get compareTypesNotMatch(){return new P({code:M.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})}static get circularReferenceFound(){return new P({code:M.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})}}!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(D||(D={}));const B=(e,t=new WeakMap)=>{if("object"==typeof e&&null!==e){if(t.has(e))throw P.circularReferenceFound;{let i;if(t.set(e,!0),Array.isArray(e))i=e.map((e=>B(e,t)));else if(e instanceof RegExp)i=e;else if(e instanceof Date)i=e;else{i={};for(const s in e)i[s]=B(e[s],t)}return t.delete(e),i}}return e},U=(e,t)=>{if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw P.compareTypesNotMatch;let i=0;switch(typeof e){case"boolean":case"number":i=e-t;break;case"string":i=e.localeCompare(t)}return i},H=(e,t)=>{let i=0;for(let t=0;t>>0)%t},V=e=>new Promise((t=>{setTimeout((()=>t()),e)})),F=(e,t)=>{if(!t)return!1;if("function"!=typeof e){for(const i in e)if(["/and","&&"].includes(i)){if(e[i].some((e=>!F(e,t))))return!1}else if(["/or","||"].includes(i)){if(e[i].every((e=>!F(e,t))))return!1}else if("/where"===i){if(!(0,e[i])(t))return!1}else{const s=i;if("object"==typeof e[s]){const i=e[s];for(const e in i)switch(e){case"/eq":case"=":if(t[s]!==i[e])return!1;break;case"/neq":case"!=":if(t[s]===i[e])return!1;break;case"/gt":case">":{const r=t[s],n=i[e];if(!(U(r,n)>0))return!1;break}case"/gte":case">=":{const r=t[s],n=i[e];if(!(U(r,n)>=0))return!1;break}case"/lt":case"<":{const r=t[s],n=i[e];if(!(U(r,n)<0))return!1;break}case"/lte":case"<=":{const r=t[s],n=i[e];if(!(U(r,n)<=0))return!1;break}case"/in":{const r=t[s];if(!i[e].includes(r))return!1;break}case"/nin":{const r=t[s];if(i[e].includes(r))return!1;break}case"/contain":{const r=t[s],n=i[e];if(!r.includes(n))return!1;break}case"/regex":{const r=t[s];if(!i[e].test(r))return!1;break}case"/where":{const r=t[s];if(!(0,i[e])(r))return!1;break}}}else if("function"==typeof e[s]){if(!e[s](t[s]))return!1}else if(e[s]!==t[s])return!1}return!0}return e(t)},q=()=>{},K=()=>Promise.resolve(),G=e=>e,z=(e,t)=>{t()};var j;!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(j||(j={}));class W{constructor({initialPrevValue:e=null,initialNextValue:t=null,iterator:i,map:s=G,backward:r=K,forward:n=K,complete:a=q}){this._prevValue=e,this._nextValue=t,this._error=null,this._map=s,this._backward=r,this._forward=n,this._iterator=i,this._complete=a}get prevValue(){return this._map(this._prevValue)}get nextValue(){return this._map(this._nextValue)}get error(){return this._error}get hasPrevious(){return!!this._prevValue}get hasNext(){return!!this._nextValue}prev(){return s.__awaiter(this,void 0,void 0,(function*(){if(this.hasPrevious){try{const e=this._prevValue;this._prevValue=(yield this._backward())||null,this._nextValue=e}catch(e){this._error=e}return yield this._iterator(this)}this._complete()}))}next(){return s.__awaiter(this,void 0,void 0,(function*(){if(this.hasNext){try{const e=this._nextValue;this._nextValue=(yield this._forward())||null,this._prevValue=e}catch(e){this._error=e}return yield this._iterator(this)}this._complete()}))}stop(){this._prevValue=null,this._nextValue=null,this._complete()}}class Y{constructor({condition:e={},backward:t=!1,blockManager:i,indexer:s}){this.condition=e,this.backward=t,this._blockManager=i,this._indexer=s}findOptimizedStartPosition(){const e=["=","/eq",">",">=","/gt","/gte"],t=["=","/eq","<","<=","/lt","/lte"];if(this.backward){let i=this._indexer.origin.length-1;if("function"!=typeof this.condition)for(const s in this._indexer.fields){let r=this._indexer.fields[s],n=1;if("-"===r[0]&&(r=r.slice(1),n=-1),this.condition[r])if("object"==typeof this.condition[r]){const a=n>0?t:e;for(const e in this.condition[r])if(a.includes(e))for(let t=i;t>=0;t--)if(n*U(this._indexer.origin[t].columnValues[s],this.condition[r][e])<=0){i=t;break}}else for(let e=i;e>=0;e--)if(n*U(this._indexer.origin[e].columnValues[s],this.condition[r])<=0){i=e;break}}return Math.min(i+1,this._indexer.origin.length-1)}{let i=0;if("function"!=typeof this.condition)for(let s=0;s{if((n>0?e:t).includes(a))for(let e=i;e=0){i=e;break}}));else for(let e=i;e=0){i=e;break}}return Math.max(i-1,0)}}each(e){return s.__awaiter(this,void 0,void 0,(function*(){let t=this.findOptimizedStartPosition(),i=0;this.backward&&this._indexer.origin[t]&&(i=this._indexer.origin[t].keys.length-1);const r=()=>{if(this._indexer.origin[t]){if(!this._indexer.origin[t].keys[++i]){if(!this._indexer.origin[++t])return!1;i=0}return!0}return!1},n=()=>{if(this._indexer.origin[t]){if(!this._indexer.origin[t].keys[--i]){if(!this._indexer.origin[--t])return!1;i=this._indexer.origin[t].keys.length-1}return!0}return!1};let a=null;if(this._indexer.origin[t]){const e=this.backward?n:r;do{const e=yield this._blockManager.getFromBlock(this._indexer.origin[t].keys[i]);if(e&&F(this.condition,e)){a=e;break}}while(e())}return yield new Promise((o=>{const l=new W({initialNextValue:B(a),iterator:e,forward:()=>s.__awaiter(this,void 0,void 0,(function*(){const e=this.backward?n:r;for(;e();){const e=yield this._blockManager.getFromBlock(this._indexer.origin[t].keys[i]);if(e&&F(this.condition,e))return B(e)}return null})),backward:()=>s.__awaiter(this,void 0,void 0,(function*(){const e=this.backward?r:n;for(;e();){const e=yield this._blockManager.getFromBlock(this._indexer.origin[t].keys[i]);if(e&&F(this.condition,e))return B(e)}return null})),complete:o});e(l)}))}))}}class ${constructor({condition:e={},backward:t=!1,mutex:i,blockManager:s,indexer:r}){this._mutex=i,this._iterator=new Y({condition:e,backward:t,blockManager:s,indexer:r})}fetch(e={}){return s.__awaiter(this,void 0,void 0,(function*(){let t=Math.max(e.offset||0,0);const i="number"==typeof e.limit?e.limit:Number.MAX_SAFE_INTEGER;if(0===i)return[];if(i<0)throw P.collectionQueryNotValid;try{const e=[];return yield this._mutex.lock(),yield this._iterator.each((r=>s.__awaiter(this,void 0,void 0,(function*(){r.error?r.stop():r.hasNext?0===t?(e.push(r.nextValue),0s.__awaiter(this,void 0,void 0,(function*(){t.error?t.stop():t.hasNext?(e++,t.next()):t.stop()})))),this._mutex.unlock(),e}catch(e){throw this._mutex.unlock(),e}}))}}const Q=e=>`nest@${e}`,Z=(e,t)=>`${Q(e)}/${t}`,J=(e,t)=>`${Z(e,t)}.metadata`,X=(e,t)=>`${Z(e,t)}/block.`,ee=(e,t)=>`${Z(e,t)}/blob.`;class te{constructor({dbname:e,collectionName:t,store:i}){this.dbname=e,this.collectionName=t,this.store=i}get(e){return s.__awaiter(this,void 0,void 0,(function*(){const t=yield this.store.get(e);if(t){const{data:e,type:i}=t;if("undefined"!=typeof fetch){const t=yield fetch(e);return yield t.blob()}{const t=512,s=[],r=atob(e.split(",")[1]);for(let e=0;e{const s=((e,t,i,s=0)=>`${ee(e,t)}${i}.${s}`)(this.dbname,this.collectionName,t),r=new FileReader;r.onload=()=>{i({blobId:s,data:r.result,type:e.type})},r.readAsDataURL(e)}));return yield this.store.set({key:i,value:{data:s,type:r}}),i}))}remove(e){return s.__awaiter(this,void 0,void 0,(function*(){yield this.store.remove(e)}))}clear(){return s.__awaiter(this,void 0,void 0,(function*(){const e=ee(this.dbname,this.collectionName),t=yield this.store.getAllKeys();yield Promise.all(t.filter((t=>t.startsWith(e))).map((e=>s.__awaiter(this,void 0,void 0,(function*(){return yield this.store.remove(e)})))))}))}}var ie,se,re;!function(e){e[e.COMMIT=0]="COMMIT",e[e.WRITE=1]="WRITE",e[e.ERROR=2]="ERROR"}(ie||(ie={})),function(e){e.PENDING="pending",e.PERSISTENT="persistent",e.VOLATILE="volatile"}(se||(se={})),function(e){e[e.NO_CACHE=0]="NO_CACHE",e[e.DEFAULT=1]="DEFAULT",e[e.PERSISTENT=2]="PERSISTENT"}(re||(re={}));const ne=[se.PENDING,se.VOLATILE],ae={};class oe{constructor({dbname:e,limit:t=256}){return ae[e]||(this.dbname=e,this._items=[],this._limit=t,ae[e]=this),ae[e]}static get(e){return ae[e]}get items(){return this._items}find(e,t,i=re.DEFAULT){return s.__awaiter(this,void 0,void 0,(function*(){let s=this.get(t);if(s)i===re.PERSISTENT&&(s.state=se.PERSISTENT);else{const r=yield e.get(t);r&&(s={key:t,value:r,state:i===re.PERSISTENT?se.PERSISTENT:se.VOLATILE},this.put(s))}return s}))}get(e,t=re.DEFAULT){const i=this._items.map((e=>e.key)).indexOf(e);if(i>-1){const e=this._items[i];return t===re.PERSISTENT&&(e.state=se.PERSISTENT),t!==re.NO_CACHE&&this.put(e),e}return null}put(e){if(this._limit>0){const t=this._items.map((e=>e.key)).indexOf(e.key);if(t>-1)ne.includes(this._items[t].state)&&ne.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);const t=this._items.filter((e=>e.state===se.VOLATILE));let i=t.length-this._limit;if(i>0){const e=[];for(const t of this._items)t.state===se.VOLATILE&&i>0?i--:e.push(t);this._items=e}}}}remove(e){const t=this._items.map((e=>e.key)).indexOf(e);t>-1&&this._items.splice(t,1)}clearByCondition(e){this._items=this._items.filter((t=>!e(t)))}clear(e=!1){this._items=e?[]:this._items.filter((e=>e.state!==se.VOLATILE))}}class le{constructor({dbname:e,collectionName:t,store:i}){this._requests=[],this._onCommit=new Map,this._onWrite=new Map,this._onError=new Map,this.dbname=e,this.collectionName=t,this.metadataKey=((e,t)=>`${Z(e,t)}/trans.metadata`)(e,t),this.recordsetKey=((e,t)=>`${Z(e,t)}/trans.recordset`)(e,t),this._store=i}get generation(){return this._metadata?this._metadata.generation:0}get requestCount(){return this._requests.length}_getReducedRecordset(e=[]){return s.__awaiter(this,void 0,void 0,(function*(){const t=(yield this._store.get(this.recordsetKey))||[];return t.push(...e),this._reduceRecordSet(t)}))}_reduceRecordSet(e){const t=[],i={};for(let s=e.length-1;s>=0;s--){const r=e[s],n=[];for(let e=r.requests.length-1;e>=0;e--){const t=r.requests[e],s=t.data;i[s.key]||(n.unshift(t),i[s.key]=!0)}n.length>0&&(r.requests=n,t.unshift(r))}return t}_applyRecord(e,t){return s.__awaiter(this,void 0,void 0,(function*(){const i=oe.get(this.dbname),{generation:s,requests:r}=t;let n=null;try{const e=yield this._store.setMany(r.map((e=>Object.assign(Object.assign({},e.data),{generation:s}))));for(let t=0;t{n&&e(n)}));else{const t=e.filter((e=>e.generation!==s));yield this._store.set({key:this.recordsetKey,value:t}),this._onWrite.forEach((e=>{e(r.map((e=>e.data)))}))}}))}init(){return s.__awaiter(this,void 0,void 0,(function*(){this._metadata=(yield this._store.get(this.metadataKey))||{generation:1};const e=yield this._getReducedRecordset();for(const t of e)yield this._applyRecord(e,t)}))}on(e,t,i){switch(e){case ie.COMMIT:this._onCommit.set(t,i);break;case ie.WRITE:this._onWrite.set(t,i);break;case ie.ERROR:this._onError.set(t,i)}}requestWrite(e,t){this._requests.push({data:e,options:t});oe.get(this.dbname).put(Object.assign({state:se.PENDING},e))}requestMultipleWrite(e,t){const i=oe.get(this.dbname);for(const s of e)this._requests.push({data:s,options:t}),i.put(Object.assign({state:se.PENDING},s))}clear(){return s.__awaiter(this,void 0,void 0,(function*(){oe.get(this.dbname).clearByCondition((e=>e.state===se.PENDING)),this._requests=[]}))}commit(){return s.__awaiter(this,void 0,void 0,(function*(){const e=this._requests;if(e.length>0){const t=[],i={};for(let s=e.length-1;s>=0;s--){const r=e[s],n=r.data;i[n.key]||(i[n.key]=!0,t.unshift(r))}const s={generation:this.generation,requests:t},r=yield this._getReducedRecordset([s]);yield this._store.set({key:this.recordsetKey,value:r}),this._metadata.generation++,yield this._store.set({key:this.metadataKey,value:this._metadata});const n=oe.get(this.dbname);for(let e=0;e{t(e.map((e=>e.data)))}));const a=R.get(this.dbname);setTimeout((()=>{try{this._applyRecord(r,s)}catch(e){this._onError.forEach((t=>t(e)))}}),a.transactionApplyDelay)}}))}}class de{constructor({blockId:e,keyName:t,items:i=[],limit:s}){this.blockId=e,this.keyName=t,this.limit=s,this._items=[...i]}static createFromCacheItem(e){return e?new de(e.value):null}get isEmpty(){return 0===this._items.length}get items(){return this._items}serialize(){return{blockId:this.blockId,keyName:this.keyName,limit:this.limit,items:this._items}}getItemByKey(e){const t=this._items.find((t=>{const i=t[this.keyName];return e===i}));return null!=t?t:null}has(e){return this._items.map((e=>e[this.keyName])).includes(e)}add(e){const t=this._items.map((e=>e[this.keyName])).indexOf(e[this.keyName]);return t<0?this._items.length{const s=i.base*Math.pow(i.multiplier,t)+i.constant;return(i.hashFunction||H)(e,s)})(e,t,{hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant})}`,`${X(i,s)}${r}.${n}`;var i,s,r,n}_findBlock(e){return s.__awaiter(this,void 0,void 0,(function*(){const t=oe.get(this.dbname);for(let i=this.metadata.blockLevel;i>0;i--){const s=this.createBlockId(e,i),r=yield t.find(this._store,s);if(r){const t=de.createFromCacheItem(r);if(null==t?void 0:t.getItemByKey(e))return t}}return null}))}getFromBlock(e){return s.__awaiter(this,void 0,void 0,(function*(){const t=yield this._findBlock(e);return t?t.getItemByKey(e):null}))}putToBlock(e,t){return s.__awaiter(this,void 0,void 0,(function*(){const i=R.get(this.dbname),s=this.createBlockId(e),r=Math.floor(this._store.itemSizeLimit/i.itemSizeLimit),n=oe.get(this.dbname),a=yield n.find(this._store,s),o=a?de.createFromCacheItem(a):new de({blockId:s,keyName:this.keyName,items:[],limit:r});return!!(null==o?void 0:o.add(t))&&(this._transaction.requestWrite({key:o.blockId,value:o.serialize()}),!0)}))}removeFromBlock(e){return s.__awaiter(this,void 0,void 0,(function*(){const t=yield this._findBlock(e);return!(!t||!t.remove(e))&&(this._transaction.requestWrite({key:t.blockId,value:t.serialize()}),!0)}))}clearAllBlocks(){return s.__awaiter(this,void 0,void 0,(function*(){const e=X(this.dbname,this.collectionName),t=(yield this._store.getAllKeys()).filter((t=>t.startsWith(e)));yield this._store.removeMany(t),yield this._transaction.clear();oe.get(this.dbname).clearByCondition((t=>t.key.startsWith(e)))}))}}const he=e=>{const t=typeof e;return null===e||"undefined"===t||"boolean"===t||"number"===t||"string"===t},_e={};class ue{constructor({dbname:e,collectionName:t,keyName:i,fields:s,transaction:r,store:n}){this._origin=[],this._table=[];const a=((e,t,i)=>`${Z(e,t)}/index.${i}`)(e,t,s.join(">"));return _e[a]||(this.dbname=e,this.collectionName=t,this.keyName=i,this.fields=s,this.indexerKey=a,this._transaction=r,this._store=n,this._transaction.on(ie.COMMIT,this.indexerKey,(()=>this.commit())),this._transaction.on(ie.ERROR,this.indexerKey,(()=>this.abort()))),_e[a]}static createKey(e){return e.join(">")}static parseKey(e){return e.split(">")}static clearIndexerMap(){for(const e in _e)delete _e[e]}_addItem(e){const t=e[this.keyName],i=this.getColumnValues(e),[s,r]=this.indexOf(i);return r?!this._table[s].keys.includes(t)&&(this._table[s].keys.push(t),!0):(this._table.splice(s,0,{columnValues:i,keys:[t]}),!0)}_removeItem(e){const t=e[this.keyName],i=this.getColumnValues(e),[s,r]=this.indexOf(i);if(r){const e=this._table[s].keys.indexOf(t);if(e>-1)return this._table[s].keys.splice(e,1),0===this._table[s].keys.length&&this._table.splice(s,1),!0}return!1}get origin(){return this._origin}get table(){return this._table}getColumnValues(e){const t=[];for(let i of this.fields){if("-"===i[0]&&(i=i.slice(1)),!he(e[i]))throw P.indexTypesNotMatch;t.push(e[i])}return t}diff(e,t){for(const i in this.fields){const s="-"===this.fields[i][0]?-1:1,r=U(e[i],t[i]);if(0!==r)return s*r}return 0}indexOf(e){if(this._table.length>0){let t=0,i=this._table.length-1;for(;t<=i;){const s=Math.floor((t+i)/2),r=this.diff(e,this._table[s].columnValues);if(r>0)t=s+1;else{if(!(r<0))return[s,!0];i=s-1}}return[t,!1]}return[0,!1]}ensure(){return s.__awaiter(this,void 0,void 0,(function*(){const e=oe.get(this.dbname),t=yield e.find(this._store,this.indexerKey,re.PERSISTENT);if(t)this._origin=t.value,this._table=B(this._origin);else{const t=X(this.dbname,this.collectionName),i=yield this._store.getAllKeys();for(const s of i)if(s.startsWith(t)){const t=yield e.find(this._store,s,re.NO_CACHE),i=de.createFromCacheItem(t);if(i)for(const e of i.items)this._addItem(e)}this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}_e[this.indexerKey]=this}))}drop(){return s.__awaiter(this,void 0,void 0,(function*(){oe.get(this.dbname).remove(this.indexerKey),yield this._store.remove(this.indexerKey),delete _e[this.indexerKey]}))}addItem(e){return s.__awaiter(this,void 0,void 0,(function*(){this._addItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}))}removeItem(e){return s.__awaiter(this,void 0,void 0,(function*(){this._removeItem(e)&&this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}))}clear(){return s.__awaiter(this,void 0,void 0,(function*(){this._table=[],this._transaction.requestWrite({key:this.indexerKey,value:this._table},{persistent:!0})}))}commit(){this._origin=this._table,this._table=B(this._origin)}abort(){this._table=B(this._origin)}}class Ee{constructor({dbname:e,collectionName:t,keyName:i,keyHash:s,indexes:r,store:n}){this._state=D.INIT,this._indexers=[],this.dbname=e,this.name=t,this.keyName=i,this.indexes=[[i],...r.filter((e=>ue.createKey(e)!==this.keyName))],this._keyHash=s,this._store=n,this._mutex=new E(((e,t)=>`${Z(e,t)}.lock`)(e,t)),this._blobContainer=new te({dbname:e,collectionName:t,store:n}),this._transaction=new le({dbname:e,collectionName:t,store:n})}static metadataOf(e,t,i){return s.__awaiter(this,void 0,void 0,(function*(){const s=J(e,t);return yield i.get(s)}))}get state(){return this._state}get isReady(){return this._state===D.READY}init(){return s.__awaiter(this,void 0,void 0,(function*(){yield this._mutex.lock();try{const e=R.get(this.dbname),t=yield Ee.metadataOf(this.dbname,this.name,this._store);this._metadata=t||{keyName:this.keyName,blockLevel:1,blockHashBase:e.blockHashBase,blockHashMultiplier:e.blockHashMultiplier,blockHashConstant:e.blockHashConstant,indexes:this.indexes},yield this._transaction.init(),this._blockManager=new ce({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store});const i=[...this.indexes],s=[],r=i.map((e=>ue.createKey(e))),n=t?t.indexes.map((e=>ue.createKey(e))):[];for(const e of n)r.includes(e)||s.push(ue.parseKey(e));const a=[];if(a.push(...i.map((e=>{const t=new ue({dbname:this.dbname,collectionName:this.name,keyName:this.keyName,fields:e,transaction:this._transaction,store:this._store});return this._indexers.push(t),t.ensure()}))),a.push(...s.map((e=>new ue({dbname:this.dbname,collectionName:this.name,keyName:this.keyName,fields:e,transaction:this._transaction,store:this._store}).drop()))),yield Promise.all(a),yield this._transaction.commit(),r.sort().join(",")!==n.sort().join(",")){const e=J(this.dbname,this.name);this._metadata.indexes=i,yield this._store.set({key:e,value:this._metadata})}this._state=D.READY,this._mutex.unlock()}catch(e){throw this._mutex.unlock(),e}}))}close(){this._state=D.CLOSED}_hasPropertyOfKeyName(e){const t=e[this.keyName];return"string"==typeof t&&!!t}_getIndexerBy(e=null){e||(e=[this.keyName]);const t=ue.createKey(e);for(const e of this._indexers)if(t===ue.createKey(e.fields))return e;throw P.indexTableIsRequired}_upgradeBlockLevel(){return s.__awaiter(this,void 0,void 0,(function*(){const e=J(this.dbname,this.name);this._metadata.blockLevel++,yield this._store.set({key:e,value:this._metadata})}))}_requestInsert(e){return s.__awaiter(this,void 0,void 0,(function*(){const t=e[this.keyName];if(yield this._blockManager.getFromBlock(t))throw P.collectionInsertDuplicate;(yield this._blockManager.putToBlock(t,e))||(yield this._upgradeBlockLevel(),yield this._blockManager.putToBlock(t,e));for(const t of this._indexers)yield t.addItem(e)}))}_requestUpsert(e){return s.__awaiter(this,void 0,void 0,(function*(){const t=e[this.keyName],i=yield this._blockManager.getFromBlock(t);if(i){yield this._blockManager.putToBlock(t,e);for(const t of this._indexers)0!==t.diff(t.getColumnValues(i),t.getColumnValues(e))&&(yield t.removeItem(i),yield t.addItem(e))}else{(yield this._blockManager.putToBlock(t,e))||(yield this._upgradeBlockLevel(),yield this._blockManager.putToBlock(t,e));for(const t of this._indexers)yield t.addItem(e)}}))}_requestUpdate(e){return s.__awaiter(this,void 0,void 0,(function*(){const t=e[this.keyName],i=yield this._blockManager.getFromBlock(t);if(i){yield this._blockManager.putToBlock(t,e);for(const t of this._indexers)0!==t.diff(t.getColumnValues(i),t.getColumnValues(e))&&(yield t.removeItem(i),yield t.addItem(e))}}))}_requestRemove(e){return s.__awaiter(this,void 0,void 0,(function*(){const t=yield this._blockManager.getFromBlock(e);if(t){yield this._blockManager.removeFromBlock(e);for(const e of this._indexers)yield e.removeItem(t)}}))}_requestClear(){return s.__awaiter(this,void 0,void 0,(function*(){yield this._blockManager.clearAllBlocks();for(const e of this._indexers)yield e.clear()}))}getByKey(e){return s.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw P.collectionNotReady;yield this._mutex.lock();try{const t=yield this._blockManager.getFromBlock(e);return this._mutex.unlock(),B(t)}catch(e){throw this._mutex.unlock(),e}}))}query(e={}){if(this.isReady)return new $({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw P.collectionNotReady}insertOne(e){return s.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw P.collectionNotReady;yield this._mutex.lock();try{if(!this._hasPropertyOfKeyName(e))throw P.collectionKeyNotGiven;return yield this._requestInsert(B(e)),yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}insertMany(e){return s.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw P.collectionNotReady;yield this._mutex.lock();try{if(e.some((e=>!this._hasPropertyOfKeyName(e))))throw P.collectionKeyNotGiven;for(const t of e)yield this._requestInsert(B(t));return yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}upsertOne(e){return s.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw P.collectionNotReady;yield this._mutex.lock();try{if(!this._hasPropertyOfKeyName(e))throw P.collectionKeyNotGiven;return yield this._requestUpsert(B(e)),yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}upsertMany(e){return s.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw P.collectionNotReady;yield this._mutex.lock();try{if(e.some((e=>!this._hasPropertyOfKeyName(e))))throw P.collectionKeyNotGiven;for(const t of e)yield this._requestUpsert(B(t));return yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}update(e){return s.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw P.collectionNotReady;yield this._mutex.lock();try{if(!this._hasPropertyOfKeyName(e))throw P.collectionKeyNotGiven;return yield this._requestUpdate(B(e)),yield this._transaction.commit(),this._mutex.unlock(),e}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}updateIf(e,t){return s.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw this._transaction.clear(),P.collectionNotReady;yield this._mutex.lock();try{const{where:i={},index:r=null,backward:n=!1}=e,a=[],o=new Y({condition:i,blockManager:this._blockManager,backward:n,indexer:this._getIndexerBy(r)});yield o.each((e=>s.__awaiter(this,void 0,void 0,(function*(){if(e.error)throw e.stop(),e.error;if(e.hasNext){const s=e.nextValue;if(F(i,s)&&t.set){if("function"!=typeof t.set)for(const e in t.set)s[e]=t.set[e];else t.set(s);a.push(s)}e.next()}else e.stop()}))));for(const e of a)yield this._requestUpdate(B(e));return yield this._transaction.commit(),this._mutex.unlock(),a}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}remove(e){return s.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw P.collectionNotReady;yield this._mutex.lock();try{yield this._requestRemove(e),yield this._transaction.commit(),this._mutex.unlock()}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}removeIf(e){return s.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw this._transaction.clear(),P.collectionNotReady;yield this._mutex.lock();try{const{where:t={},index:i=null,backward:r=!1}=e,n=[],a=new Y({condition:t,blockManager:this._blockManager,backward:r,indexer:this._getIndexerBy(i)});yield a.each((e=>s.__awaiter(this,void 0,void 0,(function*(){if(e.error)throw e.stop(),e.error;if(e.hasNext){const i=e.nextValue;if(F(t,i)){const e=i[this.keyName];n.push(e)}e.next()}else e.stop()}))));for(const e of n)yield this._requestRemove(e);return yield this._transaction.commit(),this._mutex.unlock(),n}catch(e){throw this._mutex.unlock(),e}}))}clear(){return s.__awaiter(this,void 0,void 0,(function*(){if(!this.isReady)throw P.collectionNotReady;yield this._mutex.lock();try{yield this._requestClear(),yield this._transaction.commit(),this._mutex.unlock()}catch(e){throw yield this._transaction.clear(),this._mutex.unlock(),e}}))}getBlob(e){return s.__awaiter(this,void 0,void 0,(function*(){return yield this._blobContainer.get(e)}))}saveBlob(e,t){return s.__awaiter(this,void 0,void 0,(function*(){return yield this._blobContainer.save(e,t)}))}removeBlob(e){return s.__awaiter(this,void 0,void 0,(function*(){yield this._blobContainer.remove(e)}))}removeAllBlobs(){return s.__awaiter(this,void 0,void 0,(function*(){yield this._blobContainer.clear()}))}}class me{constructor(e){var t,i,r;this.encryption=null!==(t=e.encryption)&&void 0!==t?t:s.DEFAULT_ENCRYPTION,this.itemSizeLimit=null!==(i=e.itemSizeLimit)&&void 0!==i?i:4194304,this.metadataBuffer=null!==(r=e.metadataBuffer)&&void 0!==r?r:256}_getRawKey(e,t=""){return`${e}${t}`}_generateShardPostfixArray(e=1){return[...Array(e).keys()]}_shardify(e){const{key:t,value:i}=e,s=JSON.stringify(this.encryption.encrypt(i)),r=Math.ceil(s.length/this.adjustedItemSizeLimit);return this._generateShardPostfixArray(r).map((e=>{const i={key:this._getRawKey(t,`.${e}`),data:s.substring(e*this.adjustedItemSizeLimit,(e+1)*this.adjustedItemSizeLimit)};return 0===e&&(i.metadata={shards:r}),i}))}get adjustedItemSizeLimit(){return Math.max(this.itemSizeLimit-this.metadataBuffer,4)}usage(){return s.__awaiter(this,void 0,void 0,(function*(){let e=0;const t=yield this._getAllRawKeys();for(const i of t){const t=yield this._getRaw(i);t&&(e+=JSON.stringify(t).length)}return e}))}getAllKeys(){return s.__awaiter(this,void 0,void 0,(function*(){return(yield this._getAllRawKeys()).filter((e=>e.endsWith(".0"))).map((e=>e.replace(/\.0$/,"")))}))}get(e){return s.__awaiter(this,void 0,void 0,(function*(){const t=this._getRawKey(e,".0"),i=yield this._getRaw(t);if(i)try{const{data:t,metadata:r}=i,n=(null==r?void 0:r.shards)&&r.shards>1?yield Promise.all(this._generateShardPostfixArray(null==r?void 0:r.shards).map((i=>s.__awaiter(this,void 0,void 0,(function*(){if(i>0){const t=this._getRawKey(e,`.${i}`),s=yield this._getRaw(t);if(!s)throw P.storeBrokenIntegrity;return s.data}return t}))))):[t];return this.encryption.decrypt(JSON.parse(n.join("")))}catch(e){return null}return null}))}set(e){return s.__awaiter(this,void 0,void 0,(function*(){const t=this._shardify(e);return yield this._setRaw(t),Object.assign({},e.value)}))}setMany(e){return s.__awaiter(this,void 0,void 0,(function*(){return yield this._setRaw([].concat(...e.map((e=>this._shardify(e))))),e.map((e=>e.value))}))}remove(e){return s.__awaiter(this,void 0,void 0,(function*(){const t=this._getRawKey(e,".0"),i=yield this._getRaw(t);if(i){const{metadata:t}=i;return yield this._removeRaw(this._generateShardPostfixArray(null==t?void 0:t.shards).map((t=>this._getRawKey(e,`.${t}`)))),!0}return!1}))}removeMany(e){return s.__awaiter(this,void 0,void 0,(function*(){const t=[];for(const i of e){const e=this._getRawKey(i,".0"),s=yield this._getRaw(e);if(s){const{metadata:e}=s;t.push(...this._generateShardPostfixArray(null==e?void 0:e.shards).map((e=>this._getRawKey(i,`.${e}`))))}}return t.length>0&&(yield this._removeRaw(t)),e}))}}const fe=1,ge={};class ye extends me{constructor(e={}){var t;super(Object.assign(Object.assign({},e),{itemSizeLimit:null!==(t=e.itemSizeLimit)&&void 0!==t?t:4194304}));const{delay:i=fe}=e;this.delay=i,this.observer={}}get rawData(){return ge[this.dbname]}set rawData(e){ge[this.dbname]=e}_getAllRawKeys(){return s.__awaiter(this,void 0,void 0,(function*(){if(ge[this.dbname])return Object.keys(ge[this.dbname]);throw P.storeNotAvailable}))}_getRaw(e){return s.__awaiter(this,void 0,void 0,(function*(){if(ge[this.dbname])return yield V(this.delay),ge[this.dbname][e]?Object.assign({key:e},ge[this.dbname][e]):null;throw P.storeNotAvailable}))}_setRaw(e){return s.__awaiter(this,void 0,void 0,(function*(){if(!ge[this.dbname])throw P.storeNotAvailable;yield V(this.delay);for(const t of e){const{key:e,data:i,metadata:s}=t;ge[this.dbname][e]=Object.freeze({data:i,metadata:s})}}))}_removeRaw(e){return s.__awaiter(this,void 0,void 0,(function*(){if(!ge[this.dbname])throw P.storeNotAvailable;yield V(this.delay);for(const t of e)ge[this.dbname][t]&&delete ge[this.dbname][t]}))}observe(e,t,i){this.observer[e]||(this.observer[e]={}),t.forEach((t=>this.observer[e][t]=i))}checkAvailability(){return s.__awaiter(this,void 0,void 0,(function*(){}))}init(e){return s.__awaiter(this,void 0,void 0,(function*(){this.dbname=e,ge[this.dbname]={}}))}set(e){const t=Object.create(null,{set:{get:()=>super.set}});return s.__awaiter(this,void 0,void 0,(function*(){const i=this.observer[e.key];if(i&&"function"==typeof i.set){const e=i.set();if(e)throw e}return t.set.call(this,e)}))}setMany(e){const t=Object.create(null,{setMany:{get:()=>super.setMany}});return s.__awaiter(this,void 0,void 0,(function*(){for(const t of e){const e=this.observer[t.key];if(e&&"function"==typeof e.set){const t=e.set();if(t)throw t}}return t.setMany.call(this,e)}))}clear(){return s.__awaiter(this,void 0,void 0,(function*(){yield V(this.delay),ge[this.dbname]={}}))}}const Ne="NestDBStore";var ve;!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(ve||(ve={}));const Ie="[NESTDB]";let pe=!0;class be{static off(){pe=!1}static log(...e){pe&&console.log(`${Ie}[LOG]`,...e)}static warning(...e){pe&&console.warn(`${Ie}[WARNING]`,...e)}static error(...e){pe&&console.error(`${Ie}[ERROR]`,...e)}}var Te;exports.NestDBState=void 0,(Te=exports.NestDBState||(exports.NestDBState={})).INIT="INIT",Te.OPENING="OPENING",Te.OPENED="OPENED",Te.CLOSED="CLOSED";exports.AutoResendManager=class{constructor(e,{localCacheEnabled:t,dispatcher:i,sdkState:r,logger:n}){this._iid=e,b[e]=this,this._localCacheEnabled=t,this._isProcessingAutoResend=!1,this._autoResendQueue=[],this._dispatcher=i,this._logger=n,this._sdkState=r,this._localCacheEnabled&&i.on((e=>{if(e instanceof s.ConnectionStateChangeCommand)switch(e.stateType){case s.ConnectionStateType.CONNECTED:this._isProcessingAutoResend||this.processAutoResendRegisteredPendingMessages().then((()=>this._processNextAutoResend()));break;case s.ConnectionStateType.INTERNAL_DISCONNECTED:case s.ConnectionStateType.EXTERNAL_DISCONNECTED:this._isProcessingAutoResend=!1}}))}static of(e){return b[e]}processNonAutoResendRegisteredPendingMessages(){return s.__awaiter(this,void 0,void 0,(function*(){const e=yield this._fetchAllCachedPendingMessages();for(const t of e)0===t.errorCode&&(this._logger.debug("cached pending message is not auto-resend registered. changing its sending status to failed: ",t.reqId),t.sendingStatus=s.SendingStatus.FAILED,t.errorCode=s.SendbirdErrorCode.ACK_TIMEOUT,this._dispatcher.dispatch(new s.MessageUpdateEventCommand({messages:[t],source:s.MessageEventSource.LOCAL_MESSAGE_FAILED})))}))}processAutoResendRegisteredPendingMessages(){return s.__awaiter(this,void 0,void 0,(function*(){const e=yield this._fetchAllCachedPendingMessages();for(const t of e)if(t.errorCode&&s.isAutoResendableError(t.errorCode)){const e=(new Date).getTime(),i=t.createdAt+2592e5;e<=i?this._autoResendQueue.map((e=>e.reqId)).indexOf(t.reqId)<0&&this._autoResendQueue.push(t):(this._logger.debug("auto-resend registered pending messaged expired. expiration date: ",new Date(i).toLocaleString()),t.sendingStatus=s.SendingStatus.FAILED,this._dispatcher.dispatch(new s.MessageUpdateEventCommand({messages:[t],source:s.MessageEventSource.LOCAL_MESSAGE_FAILED})))}}))}completeCurrentAndProcessNextAutoResend(e){if(this._localCacheEnabled&&(e.sendingStatus===s.SendingStatus.SUCCEEDED||e.sendingStatus===s.SendingStatus.FAILED&&!s.isAutoResendableError(e.errorCode))){const t=this.indexOf(e);t>=0&&this._autoResendQueue.splice(t,1),0===t&&this._processNextAutoResend()}}_fetchAllCachedPendingMessages(){return s.__awaiter(this,void 0,void 0,(function*(){const e=N.of(this._iid);return e?yield e.fetch({sendingStatus:s.SendingStatus.PENDING,backward:!0}):[]}))}indexOf(e){return this._autoResendQueue.length>0?this._autoResendQueue.map((e=>e.reqId)).indexOf(e.reqId):-1}_isNotInQueue(e){return-1===this._autoResendQueue.map((e=>e.reqId)).indexOf(e.reqId)}_processNextAutoResend(){return s.__awaiter(this,void 0,void 0,(function*(){if(this._localCacheEnabled&&"foreground"===this._sdkState.appState)try{if(this._autoResendQueue.length>0){this._isProcessingAutoResend||(this._logger.debug("auto-resend queue started."),this._isProcessingAutoResend=!0);const e=this._autoResendQueue[0];this._dispatcher.dispatch(new p({message:e})),this._logger.debug("processing auto-resend for message request id: ",e.reqId)}else this._logger.debug("auto-resend queue finished."),this._isProcessingAutoResend=!1}catch(e){this._logger.warn("process auto-resend error: ",e),this._isProcessingAutoResend=!1}}))}},exports.AutoResendRequestCommand=p,exports.BaseStore=me,exports.DatabaseOpenCommand=O,exports.GroupChannelRemoveEventCommand=S,exports.GroupChannelUpdateEventCommand=w,exports.IndexedDbStore=class extends me{constructor(e={}){var t;super(Object.assign(Object.assign({},e),{itemSizeLimit:null!==(t=e.itemSizeLimit)&&void 0!==t?t:104857600})),this._storeName=Ne,this._state=ve.UNINITIALIZED,this._openJobQueue=[],this._window="undefined"!=typeof window?window:void 0,this._indexedDb=this._window?this._window.indexedDB||this._window.mozIndexedDB||this._window.webkitIndexedDB||this._window.msIndexedDB:void 0}get state(){return this._state}_openDatabase(e){return new Promise(((t,i)=>{if(this._indexedDb){this._state=ve.OPENING;const s=this._indexedDb.open(e);s.addEventListener("upgradeneeded",(e=>{e.target.result.createObjectStore(Ne,{keyPath:"key"})})),s.addEventListener("success",(i=>{this._state=ve.OPEN,this._database=i.target.result,this._openJobQueue.forEach((e=>e())),this._openJobQueue=[],this._database.onclose=()=>{this._database=void 0,this._state=ve.OPENING,setTimeout((()=>{this._openDatabase(e)}),5)},t(this._database)})),s.addEventListener("error",(e=>{this._state=ve.UNINITIALIZED,i(e.target.error)}))}else i(P.storeNotAvailable)}))}_getObjectStore(e){return s.__awaiter(this,void 0,void 0,(function*(){if(this._database)return this._database.transaction(this._storeName,e).objectStore(this._storeName);switch(this._state){case ve.UNINITIALIZED:case ve.OPEN:throw P.storeNotInitialized;case ve.OPENING:case ve.CLOSED:return new Promise((t=>{this._openJobQueue.push((()=>t(this._getObjectStore(e))))}));default:return yield this._getObjectStore(e)}}))}_getAllRawKeys(){return s.__awaiter(this,void 0,void 0,(function*(){const e=yield this._getObjectStore("readonly");return yield new Promise(((t,i)=>{const s=e.getAllKeys();s.addEventListener("success",(e=>{t(e.target.result)})),s.addEventListener("error",(e=>i(e.target.error)))}))}))}_getRaw(e){return s.__awaiter(this,void 0,void 0,(function*(){const t=yield this._getObjectStore("readonly");return yield new Promise(((i,s)=>{const r=t.get(e);r.addEventListener("success",(e=>{var t;i(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.result)})),r.addEventListener("error",(e=>s(e.target.error)))}))}))}_setRaw(e){return s.__awaiter(this,void 0,void 0,(function*(){const t=yield this._getObjectStore("readwrite");yield Promise.all(e.map((e=>new Promise(((i,s)=>{const r=t.put(e);r.addEventListener("success",(e=>{i(e.target.result)})),r.addEventListener("error",(()=>{s("Failed to write.")}))})))))}))}_removeRaw(e){return s.__awaiter(this,void 0,void 0,(function*(){const t=yield this._getObjectStore("readwrite");yield Promise.all(e.map((e=>new Promise(((i,s)=>{const r=t.delete(e);r.addEventListener("success",(()=>i(e))),r.addEventListener("error",(e=>s(e.target.error)))})))))}))}_triggerDatabaseClose(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))}checkAvailability(){return s.__awaiter(this,void 0,void 0,(function*(){const e="undefined"!=typeof window?window:null;if(!((null==e?void 0:e.indexedDB)||(null==e?void 0:e.mozIndexedDB)||(null==e?void 0:e.webkitIndexedDB)||(null==e?void 0:e.msIndexedDB)))throw P.storeNotAvailable;if(this._indexedDb=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB,!this._window||!d())throw P.storeNotAvailable;if(d()&&navigator.userAgent&&navigator.userAgent.includes("Edge/")){if(!this._window.indexedDB&&(e.PointerEvent||e.MSPointerEvent))throw P.storeNotAvailableInPrivateBrowsing}else yield new Promise(((e,t)=>{if(this._indexedDb)try{const i=this._indexedDb.open("_testMozilla");i.onerror=()=>t(P.storeNotAvailableInPrivateBrowsing),i.onsuccess=()=>e()}catch(e){t(P.storeNotAvailableInPrivateBrowsing)}else t(P.storeNotAvailable)}))}))}init(e){return s.__awaiter(this,void 0,void 0,(function*(){this.dbname=e,yield this.checkAvailability(),yield this._openDatabase(e)}))}clear(){return s.__awaiter(this,void 0,void 0,(function*(){const e=yield this._getObjectStore("readwrite");return yield new Promise(((t,i)=>{const s=e.clear();s.addEventListener("success",(()=>t())),s.addEventListener("error",(e=>i(e.target.error)))}))}))}},exports.MemoryStore=ye,exports.MessageCache=I,exports.MessageFilter=a,exports.NESTDB_UNSENT_MESSAGE_COLLECTION_KEY="reqId",exports.NESTDB_UNSENT_MESSAGE_COLLECTION_NAME=g,exports.NestDB=class{constructor({name:e,version:t,store:i,config:s}){this.name=e,this._version=t,this._state=exports.NestDBState.INIT,this._config=s||new R({dbname:e}),this._store=i,this._event={success:q,error:q,storeReplaced:q,upgrade:z},this._collections=new Map,this._globalMutex=new E(`${this.name}.lock`),this._config.disableLogger&&be.off(),new oe({dbname:e,limit:this._config.cacheLimit})}get version(){return this._version}get state(){return this._state}get store(){return this._store}estimateUsage(){return s.__awaiter(this,void 0,void 0,(function*(){return yield(e=this._store,s.__awaiter(void 0,void 0,void 0,(function*(){return yield e.usage()})));var e}))}commitSchema(e){return s.__awaiter(this,void 0,void 0,(function*(){if(this._state!==exports.NestDBState.OPENING)throw P.databaseSchemaNotOnUpgrade;yield Promise.all(e.map((e=>s.__awaiter(this,void 0,void 0,(function*(){const{collectionName:t,keyName:i,index:s=[]}=e;this._collections.has(t)||this._collections.set(t,new Ee({dbname:this.name,collectionName:t,keyName:i,indexes:s,store:this._store}));const r=this._collections.get(t);r&&(yield r.init())})))))}))}open(){var e;return s.__awaiter(this,void 0,void 0,(function*(){if(yield this._globalMutex.lock(),this._state!==exports.NestDBState.OPENED){this._state=exports.NestDBState.OPENING;try{yield this._store.init(this.name);const i=(t=this.name,`${Q(t)}.metadata`),r={version:0,collectionNames:[]},n=null!==(e=yield this._store.get(i))&&void 0!==e?e:r;return new Promise(((e,t)=>{const r=e=>{n.versions.__awaiter(this,void 0,void 0,(function*(){if(t)e({continued:!1,err:t});else{n.version++,n.collectionNames=Array.from(this._collections.keys());try{yield this._store.set({key:i,value:n}),e({continued:!0})}catch(t){e({continued:!1,err:t})}}})))):e({continued:!1})},a=i=>{const{continued:o=!1,err:l=null}=i;if(o)setTimeout((()=>r(a)),10);else if(l)be.error(l.message),this._globalMutex.unlock(),this._event.error(l),t(l);else{const i=[];n.collectionNames.forEach((e=>{this._collections.has(e)||i.push((()=>s.__awaiter(this,void 0,void 0,(function*(){const t=yield Ee.metadataOf(this.name,e,this._store);if(t){const i=new Ee({dbname:this.name,collectionName:e,keyName:t.keyName,indexes:t.indexes,store:this._store});this._collections.set(e,i),yield i.init()}})))())})),Promise.all(i).then((()=>{this._state=exports.NestDBState.OPENED,this._globalMutex.unlock(),this._event.success(),e()})).catch((e=>{be.error(e.message),this._globalMutex.unlock(),this._event.error(e),t(e)}))}};r(a)}))}catch(e){switch(e.code){case M.STORE_NOT_AVAILABLE_IN_PRIVATE_BROWSING:be.warning("Access to the local storage is not allowed. Switched to MemoryStore automatically."),this._store=new ye({}),this._globalMutex.unlock(),this._event.error(e),this._event.storeReplaced(this._store),yield this.open();break;case M.STORE_NOT_AVAILABLE:be.warning("IndexedDB is not available in this environment. Switched to MemoryStore automatically. Consider using other store to save data persistently (e.g. AsyncStorage)."),this._store=new ye({}),this._globalMutex.unlock(),this._event.error(e),this._event.storeReplaced(this._store),yield this.open();break;case M.STORE_ENCRYPTION_INVALID:be.warning("Encryption algorithm has changed. Stored data would be cleared."),yield this._store.clear(),this._globalMutex.unlock(),this._event.error(e),yield this.open();break;default:throw be.error(e.message),this._globalMutex.unlock(),this._event.error(e),e}}}var t}))}close(){this._collections.forEach((e=>e.close())),this._state=exports.NestDBState.CLOSED}clear(){return s.__awaiter(this,void 0,void 0,(function*(){yield Promise.all(Array.from(this._collections.values()).map((e=>e.clear())))}))}reset(){return s.__awaiter(this,void 0,void 0,(function*(){this.close();const e=oe.get(this.name);e&&e.clearByCondition((e=>e.key.startsWith(Q(this.name)))),yield this._store.clear()}))}on(e,t){this._event[e]=t}off(e){if("function"==typeof this._event[e])if("upgrade"===e)this._event[e]=z;else this._event[e]=q}collection(e){const t=this._collections.get(e);if(t)return t;throw P.collectionNotReady}},exports.NestDBError=P,exports.ReduceDBSizeEventCommand=L,exports.ScheduledFileMessageCreateParamsDefault=f,exports.ScheduledUserMessageCreateParamsDefault=m,exports.UnsentMessageCache=N,exports.UserEvent=A,exports.UserEventCommand=x,exports.getGroupChannelIndexBy=e=>{switch(e){case exports.GroupChannelListOrder.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case exports.GroupChannelListOrder.CHRONOLOGICAL:return["-createdAt","syncIndex"];case exports.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL:return["name"];default:return["-lastMessageUpdatedAt","-createdAt","syncIndex"]}},exports.getMessageIndexBy=l,exports.shouldGiveEvent=e=>e.startsWith("EVENT_")||e===exports.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS||e===exports.GroupChannelEventSource.REFRESH_CHANNEL,exports.validateScheduledFileMessageCreateParams=e=>r.validateBaseMessageCreateParams(e)&&s.isTypeOf("number",e.scheduledAt)&&(s.isFile(e.file)||s.isTypeOf("string",e.fileUrl))&&s.isTypeOf("string",e.fileName,!0)&&s.isTypeOf("string",e.mimeType,!0)&&s.isTypeOf("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((e=>s.isTypeOf("object",e)&&e.maxWidth>0&&e.maxHeight>0))),exports.validateScheduledUserMessageCreateParams=e=>r.validateUserMessageCreateParams(e)&&s.isTypeOf("number",e.scheduledAt,!0); diff --git a/cjs/message.js b/cjs/message.js new file mode 100644 index 0000000..6992695 --- /dev/null +++ b/cjs/message.js @@ -0,0 +1 @@ +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-032c97c6.js"),t=require("./lib/__bundle-7e34e7ed.js");const s={channelUrl:"",scheduledMessageId:0};class r extends e.Module{constructor(){super(...arguments),this.name="message"}init(e,{sdkState:s,dispatcher:r,sessionManager:a,requestQueue:n,logger:i,onlineDetector:o,cacheContext:u}){super.init(e,{sdkState:s,dispatcher:r,sessionManager:a,requestQueue:n,logger:i,onlineDetector:o,cacheContext:u}),this._manager=new t.MessageManager(e,{sdkState:s,dispatcher:r,requestQueue:n,onlineDetector:o,cacheContext:u})}buildMessageFromSerializedData(e){return this._manager.buildMessageFromSerializedData(e)}buildSenderFromSerializedData(e){return this._manager.buildSenderFromSerializedData(e)}getMessage(s){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},t.MessageRetrievalParamsDefault),s);return e.unless(t.validateMessageRetrievalParams(r)).throw(e.SendbirdError.invalidParameters),this._manager.getMessage(r)}))}getScheduledMessage(t){return e.__awaiter(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},s),t);return e.unless((t=>e.isTypeOf("string",t.channelUrl)&&""!==t.channelUrl&&e.isTypeOf("number",t.scheduledMessageId)&&t.scheduledMessageId>0)(r)).throw(e.SendbirdError.invalidParameters),this._manager.getScheduledMessage(r)}))}}Object.defineProperty(exports,"MentionType",{enumerable:!0,get:function(){return e.MentionType}}),Object.defineProperty(exports,"MessageType",{enumerable:!0,get:function(){return e.MessageType}}),Object.defineProperty(exports,"MessageTypeFilter",{enumerable:!0,get:function(){return e.MessageTypeFilter}}),Object.defineProperty(exports,"PushNotificationDeliveryOption",{enumerable:!0,get:function(){return e.PushNotificationDeliveryOption}}),Object.defineProperty(exports,"ReplyType",{enumerable:!0,get:function(){return e.ReplyType}}),Object.defineProperty(exports,"SendingStatus",{enumerable:!0,get:function(){return e.SendingStatus}}),exports.AdminMessage=t.AdminMessage,exports.AppleCriticalAlertOptions=t.AppleCriticalAlertOptions,exports.BaseMessage=t.BaseMessage,exports.FileMessage=t.FileMessage,exports.MessageMetaArray=t.MessageMetaArray,exports.MessageRequestHandler=t.MessageRequestHandler,Object.defineProperty(exports,"MessageSearchOrder",{enumerable:!0,get:function(){return t.MessageSearchOrder}}),exports.MessageSearchQuery=t.MessageSearchQuery,exports.MultipleFilesMessage=t.MultipleFilesMessage,exports.MultipleFilesMessageRequestHandler=t.MultipleFilesMessageRequestHandler,exports.OGImage=t.OGImage,exports.OGMetaData=t.OGMetaData,exports.PreviousMessageListQuery=t.PreviousMessageListQuery,exports.Reaction=t.Reaction,exports.ReactionEvent=t.ReactionEvent,Object.defineProperty(exports,"ReactionEventOperation",{enumerable:!0,get:function(){return t.ReactionEventOperation}}),exports.Sender=t.Sender,exports.ThreadInfo=t.ThreadInfo,exports.ThreadInfoUpdateEvent=t.ThreadInfoUpdateEvent,exports.Thumbnail=t.Thumbnail,exports.UploadedFileInfo=t.UploadedFileInfo,exports.UserMessage=t.UserMessage,exports.MessageModule=r; diff --git a/cjs/openChannel.js b/cjs/openChannel.js new file mode 100644 index 0000000..c56deff --- /dev/null +++ b/cjs/openChannel.js @@ -0,0 +1 @@ +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-032c97c6.js"),n=require("./lib/__bundle-aa0921e3.js"),t=require("./lib/__bundle-7e34e7ed.js");require("./lib/__bundle-481ecf03.js");var a=require("./lib/__bundle-aba6d9af.js"),s=require("./lib/__bundle-91cccea4.js");class r extends e.InstancedObject{constructor(){super(...arguments),this._channels=new Map,this._enteredChannelUrls=[]}get enteredChannels(){return this._enteredChannelUrls.map((e=>this._channels.get(e))).filter((e=>!!e))}isEnteredChannel(e){return this._enteredChannelUrls.includes(e)}enter(e){this._enteredChannelUrls.indexOf(e)<0&&this._enteredChannelUrls.push(e)}exit(e){const n=this._enteredChannelUrls.indexOf(e);n>=0&&this._enteredChannelUrls.splice(n,1)}exitAll(){this._enteredChannelUrls=[]}get(n){return e.__awaiter(this,void 0,void 0,(function*(){return this._channels.get(n)}))}upsert(n){return e.__awaiter(this,void 0,void 0,(function*(){const e=[];return n.forEach((n=>{if(this._channels.has(n.url)){const t=this._channels.get(n.url);Object.assign(t,n),e.push(t)}else this._channels.set(n.url,n),e.push(n)})),e}))}remove(n){return e.__awaiter(this,void 0,void 0,(function*(){this._channels.delete(n),this.exit(n)}))}clear(){return e.__awaiter(this,void 0,void 0,(function*(){this._channels.clear(),this._enteredChannelUrls=[]}))}}const i={channelUrl:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0};class o extends e.APIRequestCommand{constructor({channelUrl:n,isInternalCall:t}){super(),this.method=e.APIRequestMethod.GET,this.path=`${t?e.API_PATH_OPEN_CHANNELS_INTERNAL:e.API_PATH_OPEN_CHANNELS}/${encodeURIComponent(n)}`}}class l extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channel=new T(e,n)}}class h extends e.APIRequestCommand{constructor(n){const{channelUrl:t,coverUrlOrImage:a,name:s,data:r,customType:i,operatorUserIds:o,isEphemeral:l}=n;super(),this.method=e.APIRequestMethod.POST,this.path=e.API_PATH_OPEN_CHANNELS,this.params=e.deundefined(e.undefineNullProps({channel_url:t,cover_url:e.isTypeOf("string",a)?a:null,cover_file:e.isFile(a)?a:null,name:s,data:r,custom_type:i,operators:o,is_ephemeral:l}))}}class d extends e.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"ENTR",payload:{channel_url:e},ackRequired:!0})}}class c extends a.ChannelEventCommand{constructor(n,t,a){var s,r;super(n,"SYEV",a),a.data&&(this.participantCount=null!==(s=a.data.participant_count)&&void 0!==s?s:0,this.user=new e.User(n,a.data),this.ts=null!==(r=a.data.edge_ts)&&void 0!==r?r:0)}}class u extends e.WebSocketRequestCommand{constructor({channelUrl:e}){super({code:"EXIT",payload:{channel_url:e},ackRequired:!0})}}class C extends a.ChannelEventCommand{constructor(n,t,a){var s,r;super(n,"EXIT",a),a.data&&(this.participantCount=null!==(s=a.data.participant_count)&&void 0!==s?s:0,this.user=new e.User(n,a.data),this.ts=null!==(r=a.data.edge_ts)&&void 0!==r?r:0)}}const p={};class _{constructor(n,{sdkState:t,dispatcher:a,requestQueue:s}){return p[n]||(this._iid=n,this._sdkState=t,this._requestQueue=s,this._dispatcher=a,this._openChannelCache=new r(n),this._openChannelHandlers=new Map,this._dispatcher.on((n=>{if(n instanceof e.WebSocketEventCommand)this._handleEvent(n);else if(n instanceof e.ConnectionStateChangeCommand&&n.stateType===e.ConnectionStateType.CONNECTED){const{enteredChannels:e}=this._openChannelCache;for(const n of e)n.enter()}})),p[n]=this),p[n]}static of(e){return p[e]}buildOpenChannelFromSerializedData(n){const t=e.deserialize(n);return new T(this._iid,T.payloadify(t))}getChannelFromCache(n){var t;return e.__awaiter(this,void 0,void 0,(function*(){return null!==(t=yield this._openChannelCache.get(n))&&void 0!==t?t:null}))}upsertChannelsToCache(n){return e.__awaiter(this,void 0,void 0,(function*(){return yield this._openChannelCache.upsert(n)}))}removeChannelsFromCache(n){return e.__awaiter(this,void 0,void 0,(function*(){for(const e of n)yield this._openChannelCache.remove(e)}))}setEnteredToCache(e){this._openChannelCache.enter(e.url)}setExitedToCache(e){this._openChannelCache.exit(e.url)}_handleEvent(s){return e.__awaiter(this,void 0,void 0,(function*(){try{switch(s.code){case"MESG":case"FILE":case"ADMM":case"BRDM":{let r=null;if("MESG"===s.code?r=s.as(n.UserMessageEventCommand):"FILE"===s.code?r=s.as(t.FileMessageEventCommand):"ADMM"!==s.code&&"BRDM"!=s.code||(r=s.as(a.AdminMessageEventCommand)),r){const{message:n,isMentioned:t}=r;if(n.channelType===e.ChannelType.OPEN){const a=yield this.getChannel(n.channelUrl,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(a.url)&&(e.onMessageReceived&&e.onMessageReceived(a,n),t&&e.onMentionReceived&&e.onMentionReceived(a,n))}))))}}break}case"MEDI":case"FEDI":case"AEDI":{let t=null;if("MEDI"===s.code?t=s.as(n.UpdateUserMessageEventCommand):"FEDI"===s.code?t=s.as(n.UpdateFileMessageEventCommand):"AEDI"===s.code&&(t=s.as(a.UpdateAdminMessageEventCommand)),t){const{message:n,mentionCountChange:a}=t;if(n.channelType===e.ChannelType.OPEN){const t=yield this.getChannel(n.channelUrl,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(t.url)&&(e.onMessageUpdated&&e.onMessageUpdated(t,n),a>0&&e.onMentionReceived&&e.onMentionReceived(t,n))}))))}}break}case"DELM":{const{channelUrl:t,channelType:a,messageId:r}=s.as(n.DeleteMessageEventCommand);if(a===e.ChannelType.OPEN){const n=yield this.getChannel(t,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(n.url)&&e.onMessageDeleted&&e.onMessageDeleted(n,r)}))))}break}case"MRCT":{const{channelUrl:n,channelType:t,event:r}=s.as(a.ReactionEventCommand);if(t===e.ChannelType.OPEN){const t=yield this.getChannel(n,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(t.url)&&e.onReactionUpdated&&e.onReactionUpdated(t,r)}))))}break}case"MTHD":{const{event:n}=s.as(a.ThreadInfoUpdateEventCommand);if(n.channelType===e.ChannelType.OPEN){const t=yield this.getChannel(n.channelUrl,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())this._openChannelCache.isEnteredChannel(t.url)&&e.onThreadInfoUpdated&&e.onThreadInfoUpdated(t,n)}))))}break}case"MCNT":{const{openChannelMemberCounts:n}=s.as(a.MemberCountUpdateEventCommand),t=[];for(const e of n){const{channelUrl:n,participantCount:a,updatedAt:s}=e,r=yield this.getChannelFromCache(n);r&&r._updateParticipantCount(a,s)&&t.push(r)}if(t.length>0){const n=yield this.upsertChannelsToCache(t);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged(n)}))))}break}case"PEDI":{const{event:n,status:t,channelUrl:r,channelType:i}=s.as(a.PollUpdateEventCommand);if(r&&i===e.ChannelType.OPEN){const a=yield this.getChannel(r,!0);this._dispatcher.dispatch(new e.PollUpdateInternalEventCommand({event:n,source:e.MessageEventSource.EVENT_POLL_UPDATED})),t===e.POLL_REMOVED_STATUS?e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onPollDeleted&&e.onPollDeleted(a,n.pollId)})))):e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onPollUpdated&&e.onPollUpdated(a,n)}))))}break}case"VOTE":{const{event:t,channelUrl:a,channelType:r}=s.as(n.PollVoteEventCommand);if(a&&r===e.ChannelType.OPEN){const n=yield this.getChannel(a,!0);this._dispatcher.dispatch(new e.PollVoteInternalEventCommand({event:t,source:e.MessageEventSource.EVENT_POLL_VOTED})),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){for(const e of this._openChannelHandlers.values())e.onPollVoted&&e.onPollVoted(n,t)}))))}break}case"SYEV":{const{event:t}=s.as(a.ChannelEventCommand);if(t.isOpenChannelEvent)switch(t.category){case a.ChannelEventCategory.CHANNEL_ENTER:{const n=yield this.getChannel(t.channelUrl,!0),{participantCount:a,user:r}=s.as(c),i=n._updateParticipantCount(a,t.ts);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onUserEntered&&e.onUserEntered(n,r),i&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(n)}))}))));break}case a.ChannelEventCategory.CHANNEL_EXIT:{const n=yield this.getChannel(t.channelUrl,!0),{participantCount:a,user:r}=s.as(C),i=n._updateParticipantCount(a,t.ts);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onUserExited&&e.onUserExited(n,r),i&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(n)}))}))));break}case a.ChannelEventCategory.CHANNEL_OPERATOR_UPDATE:{const n=yield this.getChannel(t.channelUrl,!0),{operators:r}=s.as(a.OperatorUpdateEventCommand);n.operators=r,this.upsertChannelsToCache([n]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onOperatorUpdated&&e.onOperatorUpdated(n,r)}))}))));break}case a.ChannelEventCategory.USER_CHANNEL_MUTE:case a.ChannelEventCategory.USER_CHANNEL_UNMUTE:{const r=yield this.getChannel(t.channelUrl,!0),i=t.category===a.ChannelEventCategory.USER_CHANNEL_MUTE,{user:o}=s.as(i?n.MuteUserEventCommand:n.UnmuteUserEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i?e.onUserMuted&&e.onUserMuted(r,o):e.onUserUnmuted&&e.onUserUnmuted(r,o)}))}))));break}case a.ChannelEventCategory.USER_CHANNEL_BAN:case a.ChannelEventCategory.USER_CHANNEL_UNBAN:{const r=yield this.getChannel(t.channelUrl,!0),i=t.category===a.ChannelEventCategory.USER_CHANNEL_BAN,{user:o}=s.as(i?n.BanUserEventCommand:n.UnbanUserEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{i?e.onUserBanned&&e.onUserBanned(r,o):e.onUserUnbanned&&e.onUserUnbanned(r,o)}))}))));break}case a.ChannelEventCategory.CHANNEL_FREEZE:case a.ChannelEventCategory.CHANNEL_UNFREEZE:{const a=yield this.getChannel(t.channelUrl,!0),{freeze:r}=s.as(n.FreezeEventCommand);a.isFrozen=r,this.upsertChannelsToCache([a]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r?e.onChannelFrozen&&e.onChannelFrozen(a):e.onChannelUnfrozen&&e.onChannelUnfrozen(a)}))}))));break}case a.ChannelEventCategory.CHANNEL_DELETED:{const n=yield this.getChannel(t.channelUrl,!0);yield this.removeChannelsFromCache([n.url]),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onChannelDeleted&&e.onChannelDeleted(n.url,n.channelType)}))}))));break}case a.ChannelEventCategory.CHANNEL_PROP_CHANGED:{const n=yield this.getChannelWithoutCache(t.channelUrl,!0);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{e.onChannelChanged&&e.onChannelChanged(n)}))}))));break}case a.ChannelEventCategory.CHANNEL_META_DATA_CHANGED:{const a=yield this.getChannel(t.channelUrl,!0),{created:r,updated:i,deleted:o}=s.as(n.UpdateMetaDataEventCommand);r&&a._upsertCachedMetaData(r,t.ts),i&&a._upsertCachedMetaData(i,t.ts),o&&a._removeFromCachedMetaData(o,t.ts),e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r&&e.onMetaDataCreated&&e.onMetaDataCreated(a,r),i&&e.onMetaDataUpdated&&e.onMetaDataUpdated(a,i),o&&e.onMetaDataDeleted&&e.onMetaDataDeleted(a,o)}))}))));break}case a.ChannelEventCategory.CHANNEL_META_COUNTERS_CHANGED:{const a=yield this.getChannel(t.channelUrl,!0),{created:r,updated:i,deleted:o}=s.as(n.UpdateMetaCounterEventCommand);e.runAsCallback((()=>e.__awaiter(this,void 0,void 0,(function*(){this._openChannelHandlers.forEach((e=>{r&&e.onMetaCounterCreated&&e.onMetaCounterCreated(a,r),i&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(a,i),o&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(a,o)}))}))));break}}break}}}catch(n){if(e.isThrowingOutside(n))throw n}}))}addHandler(e,n){this._openChannelHandlers.set(e,n)}removeHandler(e){this._openChannelHandlers.delete(e)}clearHandler(){this._openChannelHandlers.clear()}getChannel(n,t=!1){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters);try{const e=yield this.getChannelFromCache(n);if(e)return e}catch(e){}return yield this.getChannelWithoutCache(n)}))}getChannelWithoutCache(n,t=!1){return e.__awaiter(this,void 0,void 0,(function*(){e.unless(e.isTypeOf("string",n)).throw(e.SendbirdError.invalidParameters);const a=new o({channelUrl:n,isInternalCall:t}),s=yield this._requestQueue.send(a),{channel:r}=s.as(l);return(yield this.upsertChannelsToCache([r]))[0]}))}createChannel(n){return e.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},i),n);e.unless((n=>e.isArrayOf("string",n.operatorUserIds,!0)&&(e.isTypeOf("string",n.coverUrlOrImage,!0)||e.isFile(n.coverUrlOrImage,!0))&&e.isTypeOf("string",n.name,!0)&&e.isTypeOf("string",n.data,!0)&&e.isTypeOf("string",n.customType,!0)&&(e.isTypeOf("string",n.channelUrl)&&/^\w+$/.test(n.channelUrl)||null===n.channelUrl||void 0===n.channelUrl)&&e.isTypeOf("boolean",n.isEphemeral,!0))(t)).throw(e.SendbirdError.invalidParameters);const a=new h(t),s=yield this._requestQueue.send(a),{channel:r}=s.as(l);return this.upsertChannelsToCache([r]),r}))}}const v={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0};class m extends e.APIRequestCommand{constructor(n){const{channelUrl:t,token:a,limit:s}=n;super(),this.method=e.APIRequestMethod.GET,this.path=`${e.API_PATH_OPEN_CHANNELS}/${encodeURIComponent(t)}/participants`,this.params={token:a,limit:s}}}class E extends e.APIResponseCommand{constructor(e,n){super(e,n),this.participants=[];const{next:t,participants:a}=n;this.token=t,this.participants=a.map((n=>new s.Participant(e,n)))}}class f extends e.ChannelDataListQuery{constructor(n,t,a){super(n,t,e.ChannelType.OPEN,a)}_validate(){return super._validate()}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:n}=e.Vault.of(this._iid),t=new m(Object.assign(Object.assign({},this),{token:this._token})),a=yield n.send(t),{participants:s,token:r}=a.as(E);return this._token=r,this._hasNext=!!r,this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class g extends e.APIRequestCommand{constructor(n){const{channelUrl:t,coverUrlOrImage:a,name:s,data:r,customType:i,operatorUserIds:o}=n;super(),this.method=e.APIRequestMethod.PUT,this.path=`${e.API_PATH_OPEN_CHANNELS}/${encodeURIComponent(t)}`,this.params=e.deundefined(e.undefineNullProps({cover_url:e.isTypeOf("string",a)?a:null,cover_file:e.isFile(a)?a:null,name:s,data:r,custom_type:i,operators:o}))}}class y extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channel=new T(e,n)}}class U extends e.APIRequestCommand{constructor(n){const{channelUrl:t}=n;super(),this.method=e.APIRequestMethod.DELETE,this.path=`${e.API_PATH_OPEN_CHANNELS}/${encodeURIComponent(t)}`}}class T extends n.BaseChannel{constructor(n,t){var a;super(n,t),this._lastParticipantCountUpdated=0,this.participantCount=0,this.operators=[],this.channelType=e.ChannelType.OPEN,this.participantCount=null!==(a=t.participant_count)&&void 0!==a?a:0,this.operators=Array.isArray(t.operators)?t.operators.map((t=>new e.User(n,t))):[]}static payloadify(t){return e.deundefined(e.undefineNullProps(Object.assign(Object.assign({},n.BaseChannel.payloadify(t)),{participant_count:t.participantCount,operators:t.operators.map((n=>e.User.payloadify(n)))})))}serialize(){return e.serialize(this)}isOperator(n){return n instanceof e.User?this.isOperator(n.userId):this.operators.some((e=>e.userId===n))}_updateParticipantCount(e,n){return n>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=n,!0)}createParticipantListQuery(e){return new f(this._iid,this.url,e)}refresh(){return e.__awaiter(this,void 0,void 0,(function*(){const e=_.of(this._iid);return yield e.getChannelWithoutCache(this.url)}))}enter(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:n}=e.Vault.of(this._iid),t=new d({channelUrl:this.url}),a=yield n.send(t),{participantCount:s,ts:r}=a.as(c);this._updateParticipantCount(s,r);_.of(this._iid).setEnteredToCache(this)}))}exit(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:n}=e.Vault.of(this._iid),a=new u({channelUrl:this.url}),s=yield n.send(a),{participantCount:r,ts:i}=s.as(C);this._updateParticipantCount(r,i);_.of(this._iid).setExitedToCache(this);t.MessageManager.of(this._iid).fileMessageQueue.cancel(this)}))}updateChannel(n){return e.__awaiter(this,void 0,void 0,(function*(){const t=Object.assign(Object.assign({},v),n);e.unless((n=>e.isArrayOf("string",n.operatorUserIds,!0)&&(e.isTypeOf("string",n.coverUrlOrImage)||e.isFile(n.coverUrlOrImage)||null===n.coverUrlOrImage)&&e.isTypeOf("string",n.name,!0)&&e.isTypeOf("string",n.data,!0)&&e.isTypeOf("string",n.customType,!0))(t)).throw(e.SendbirdError.invalidParameters);const{requestQueue:a}=e.Vault.of(this._iid),s=new g(Object.assign({channelUrl:this.url},t)),r=yield a.send(s),{channel:i}=r.as(y);this._update(i);const o=_.of(this._iid);return yield o.upsertChannelsToCache([i]),this}))}updateChannelWithOperatorUserIds(n,t,a,s,r){return e.__awaiter(this,void 0,void 0,(function*(){const e=Object.assign(Object.assign({},v),{name:n,coverUrlOrImage:t,data:a,operatorUserIds:s,customType:r});return this.updateChannel(e)}))}delete(){return e.__awaiter(this,void 0,void 0,(function*(){const{requestQueue:n}=e.Vault.of(this._iid),t=new U({channelUrl:this.url});yield n.send(t);const a=_.of(this._iid);yield a.removeChannelsFromCache([this.url])}))}sendUserMessage(n){return e.unless(!n.isPinnedMessage).throw(e.SendbirdError.notSupportedError),super.sendUserMessage(n)}sendFileMessage(n){return e.unless(!n.isPinnedMessage).throw(e.SendbirdError.notSupportedError),super.sendFileMessage(n)}}class P extends a.BaseChannelHandlerParams{constructor(){super(...arguments),this.onUserEntered=e.noop,this.onUserExited=e.noop,this.onChannelParticipantCountChanged=e.noop,this.onPollUpdated=e.noop,this.onPollVoted=e.noop,this.onPollDeleted=e.noop}}class O extends e.APIRequestCommand{constructor(n){const{token:t,limit:a,nameKeyword:s,urlKeyword:r,customTypes:i,includeFrozen:o,includeMetaData:l}=n;super(),this.method=e.APIRequestMethod.GET,this.path=e.API_PATH_OPEN_CHANNELS,this.params=e.deundefined({token:t,limit:a,name_contains:s,url_contains:r,custom_types:i,show_frozen:o,show_metadata:l})}}class A extends e.APIResponseCommand{constructor(e,n){super(e,n),this.channels=[];const{next:t,channels:a,ts:s}=n;this.token=t,a&&a.length>0&&(this.channels=a.map((n=>new T(e,n)))),this.ts="number"==typeof s?s:null}}class b extends e.BaseListQuery{constructor(e,n){var t,a,s,r,i;super(e,n),this.includeFrozen=!0,this.includeMetaData=!0,this.nameKeyword=null,this.urlKeyword=null,this.customTypes=null,this.includeFrozen=null===(t=n.includeFrozen)||void 0===t||t,this.includeMetaData=null===(a=n.includeMetaData)||void 0===a||a,this.nameKeyword=null!==(s=n.nameKeyword)&&void 0!==s?s:null,this.urlKeyword=null!==(r=n.urlKeyword)&&void 0!==r?r:null,this.customTypes=null!==(i=n.customTypes)&&void 0!==i?i:null}_validate(){return super._validate()&&e.isTypeOf("boolean",this.includeFrozen)&&e.isTypeOf("boolean",this.includeMetaData)&&e.isTypeOf("string",this.nameKeyword,!0)&&e.isTypeOf("string",this.urlKeyword,!0)&&e.isArrayOf("string",this.customTypes,!0)}next(){return e.__awaiter(this,void 0,void 0,(function*(){if(this._validate()){if(this._isLoading)throw e.SendbirdError.queryInProgress;if(this._hasNext){this._isLoading=!0;const{requestQueue:n}=e.Vault.of(this._iid),t=new O(e.undefineNullProps(Object.assign(Object.assign({},this),{token:this._token}))),a=yield n.send(t),{channels:s,token:r}=a.as(A);this._token=r,this._hasNext=!!r;const i=_.of(this._iid);return yield i.upsertChannelsToCache(s),this._isLoading=!1,s}return[]}throw e.SendbirdError.invalidParameters}))}}class w extends e.Module{constructor(){super(...arguments),this.name="openChannel"}init(e,{sdkState:n,dispatcher:t,sessionManager:a,requestQueue:s,logger:r,onlineDetector:i,cacheContext:o}){super.init(e,{sdkState:n,dispatcher:t,sessionManager:a,requestQueue:s,logger:r,onlineDetector:i,cacheContext:o}),this._manager=new _(e,{sdkState:n,dispatcher:t,requestQueue:s})}createOpenChannelListQuery(e={}){return new b(this._iid,e)}addOpenChannelHandler(e,n){this._manager.addHandler(e,n)}removeOpenChannelHandler(e){this._manager.removeHandler(e)}removeAllOpenChannelHandlers(){this._manager.clearHandler()}buildOpenChannelFromSerializedData(e){return this._manager.buildOpenChannelFromSerializedData(e)}getChannel(n){return e.__awaiter(this,void 0,void 0,(function*(){return this._manager.getChannel(n)}))}getChannelWithoutCache(n){return e.__awaiter(this,void 0,void 0,(function*(){return this._manager.getChannelWithoutCache(n)}))}createChannel(n={}){return e.__awaiter(this,void 0,void 0,(function*(){return this._manager.createChannel(n)}))}createChannelWithOperatorUserIds(n,t,a,s,r){return e.__awaiter(this,void 0,void 0,(function*(){const e=Object.assign({},i);return e.name=n,e.coverUrlOrImage=t,e.data=a,e.operatorUserIds=s,e.customType=r,this._manager.createChannel(e)}))}}exports.OpenChannel=T,exports.OpenChannelHandler=class extends P{constructor(e={}){super(),Object.keys(e).forEach((n=>{this.hasOwnProperty(n)&&(this[n]=e[n])}))}},exports.OpenChannelListQuery=b,exports.OpenChannelModule=w,exports.ParticipantListQuery=f; diff --git a/cjs/package.json b/cjs/package.json new file mode 100644 index 0000000..73b8e16 --- /dev/null +++ b/cjs/package.json @@ -0,0 +1,80 @@ +{ + "version": "4.9.4-rc.1", + "description": "Sendbird SDK for JavaScript", + "name": "@sendbird/chat", + "author": "Sendbird ", + "keywords": [ + "sendbird", + "sendbird.com", + "messaging", + "chat", + "js" + ], + "license": "SEE LICENSE IN LICENSE.md", + "homepage": "https://sendbird.com", + "repository": { + "type": "git", + "url": "https://github.com/sendbird/sendbird-chat-sdk-javascript" + }, + "peerDependencies": { + "@react-native-async-storage/async-storage": "^1.17.6" + }, + "peerDependenciesMeta": { + "@react-native-async-storage/async-storage": { + "optional": true + } + }, + "main": "cjs/index.js", + "module": "index.js", + "types": "index.d.ts", + "type": "commonjs", + "react-native": "./index.js", + "exports": { + ".": { + "types": "./index.d.ts", + "import": "./index.js", + "require": "./cjs/index.js", + "default": "./index.js" + }, + "./message": { + "types": "./message.d.ts", + "import": "./message.js", + "require": "./cjs/message.js", + "default": "./message.js" + }, + "./groupChannel": { + "types": "./groupChannel.d.ts", + "import": "./groupChannel.js", + "require": "./cjs/groupChannel.js", + "default": "./groupChannel.js" + }, + "./openChannel": { + "types": "./openChannel.d.ts", + "import": "./openChannel.js", + "require": "./cjs/openChannel.js", + "default": "./openChannel.js" + }, + "./poll": { + "types": "./poll.d.ts", + "import": "./poll.js", + "require": "./cjs/poll.js", + "default": "./poll.js" + } + }, + "typesVersions": { + "*": { + "message": [ + "./message.d.ts" + ], + "groupChannel": [ + "./groupChannel.d.ts" + ], + "openChannel": [ + "./openChannel.d.ts" + ], + "poll": [ + "./poll.d.ts" + ] + } + } +} \ No newline at end of file diff --git a/cjs/poll.js b/cjs/poll.js new file mode 100644 index 0000000..f118d84 --- /dev/null +++ b/cjs/poll.js @@ -0,0 +1 @@ +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./lib/__bundle-032c97c6.js"),t=require("./lib/__bundle-481ecf03.js");class r extends e.Module{constructor(){super(...arguments),this.name="poll"}init(e,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n}){super.init(e,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n}),this._manager=new t.PollManager(e,{sdkState:r,dispatcher:a,sessionManager:o,requestQueue:l,logger:s,onlineDetector:i,cacheContext:n})}create(r){return e.__awaiter(this,void 0,void 0,(function*(){const a=Object.assign(Object.assign({},t.PollCreateParamsDefault),r);return e.unless(t.validatePollCreateParams(a)).throw(e.SendbirdError.invalidParameters),this._manager.create(a)}))}get(r){return e.__awaiter(this,void 0,void 0,(function*(){const a=Object.assign(Object.assign({},t.PollRetrievalParamsDefault),r);return e.unless(t.validatePollRetrievalParams(a)).throw(e.SendbirdError.invalidParameters),this._manager.get(a)}))}getOption(r){return e.__awaiter(this,void 0,void 0,(function*(){const a=Object.assign(Object.assign({},t.PollOptionRetrievalParamsDefault),r);return e.unless(t.validatePollOptionRetrievalParams(a)).throw(e.SendbirdError.invalidParameters),this._manager.getOption(a)}))}buildPollFromSerializedData(e){return this._manager.buildPollFromSerializedData(e)}}exports.Poll=e.Poll,exports.PollOption=e.PollOption,Object.defineProperty(exports,"PollStatus",{enumerable:!0,get:function(){return e.PollStatus}}),exports.PollListQuery=t.PollListQuery,exports.PollUpdateEvent=t.PollUpdateEvent,exports.PollVoteEvent=t.PollVoteEvent,exports.PollVoterListQuery=t.PollVoterListQuery,exports.PollModule=r; diff --git a/groupChannel.js b/groupChannel.js index 511d8f3..84adea4 100644 --- a/groupChannel.js +++ b/groupChannel.js @@ -1 +1 @@ -import{_ as e,e as r,u as s,g as i,M as a,X as o,Q as u,U as c,a0 as h,aF as d,t as f,S as _,r as m,s as v,b as g,c as y,K as C,m as E,a as b,i as M,a7 as N,J as U,aE as S,aG as T,ax as A,aH as I,ak as w,aj as L,A as D,d as k,f as R,h as F,aI as x,ah as O,aJ as H,aa as V,W as q,a3 as B,B as W,w as z,V as j,R as Q,aD as K,z as Y,ai as J,ad as X,aK as Z,E as $,x as ee,y as te,ag as ne,ab as re,aL as se,aM as ie,aN as ae,p as oe,a5 as ue,aO as ce,am as le,a4 as he,aC as de,ae as pe,N as fe,n as _e,an as me}from"./lib/__bundle-75942676.js";export{ai as MessageEventSource}from"./lib/__bundle-75942676.js";import{g as ve,N as ge,p as ye,q as Ce,r as Ee,t as be,u as Me,w as Ne,x as Ue,y as Se,P as Te,z as Ae,A as Ie,C as we,E as Le,D as De,G as ke,H as Pe,I as Re,J as Fe,f as xe,K as Oe,L as He}from"./lib/__bundle-e875840b.js";import{G as Ge,g as Ve,D as qe,l as Be,m as We,n as ze,j as je,i as Qe,o as Ke,R as Ye,p as Je,k as Xe,U as Ze,e as $e,f as et,s as tt,d as nt,S as rt,v as st,q as it,r as at,P as ot,t as ut}from"./lib/__bundle-fd51cf65.js";export{n as GroupChannelEventSource,G as GroupChannelListOrder,p as MessageFilter,P as PublicGroupChannelListOrder,t as ScheduledMessageListOrder}from"./lib/__bundle-fd51cf65.js";import{C as ct,a as lt,O as ht,P as dt,M as pt,T as ft,R as _t,U as mt,A as vt,B as gt}from"./lib/__bundle-361d5a90.js";import{l as yt,S as Ct,I as Et,p as bt,U as Mt,F as Nt,m as Ut,c as St,T as Tt,d as At,A as It,n as wt,g as Lt,h as Dt,o as kt,q as Pt}from"./lib/__bundle-84f74e8d.js";export{l as ScheduledStatus}from"./lib/__bundle-84f74e8d.js";import{b as Rt}from"./lib/__bundle-ad161b2c.js";var Ft;!function(e){e.NONE="none",e.JOINED="joined",e.INVITED="invited",e.LEFT="left"}(Ft||(Ft={}));var xt,Ot,Ht,Gt,Vt,qt,Bt,Wt,zt=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=a(Ft,n.state)?n.state:null,r.role=a(o,n.role)?n.role:null,"boolean"==typeof n.is_muted&&(r.isMuted=n.is_muted),"boolean"==typeof n.is_blocked_by_me&&(r.isBlockedByMe=n.is_blocked_by_me),"boolean"==typeof n.is_blocking_me&&(r.isBlockingMe=n.is_blocking_me),r}return e(n,t),n.payloadify=function(e){return r(s(i(i({},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})))},n}(ve),jt=function(t){function n(e,n){var r,s,i=this;return(i=t.call(this,e)||this).channelUrl=null!==(r=n.channel_url)&&void 0!==r?r:"",i.channelType=null!==(s=n.channel_type)&&void 0!==s?s:u.GROUP,i.reader=new c(i._iid,n.user),i.readAt=n.ts,i}return e(n,t),n}(h);!function(e){e.ALL="all",e.PUBLIC="public",e.PRIVATE="private"}(xt||(xt={})),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"}(Ot||(Ot={})),function(e){e.ALL="all",e.SUPER="super",e.NON_SUPER="nonsuper",e.BROADCAST_ONLY="broadcast_only",e.EXCLUSIVE_ONLY="exclusive_only"}(Ht||(Ht={})),function(e){e.ALL="all",e.UNREAD_MESSAGE="unread_message"}(Gt||(Gt={})),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"}(Vt||(Vt={})),function(e){e.ALL="all",e.OPERATOR="operator",e.NONOPERATOR="nonoperator"}(qt||(qt={})),function(e){e.AND="AND",e.OR="OR"}(Bt||(Bt={})),function(e){e.MEMBER_NICKNAME="member_nickname",e.CHANNEL_NAME="channel_name"}(Wt||(Wt={}));var Qt,Kt=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=Ot.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=Ht.ALL,this.publicChannelFilter=xt.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=Gt.ALL,this.hiddenChannelFilter=Vt.UNHIDDEN,this.includeFrozen=!0}return e.prototype._isFriend=function(e){return!(!e||!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=Bt.AND),this._userIdsFilter={userIds:e,includeMode:t,queryType:n}},e.prototype.clone=function(){var t,n=new e;this.searchFilter&&n.setSearchFilter(this.searchFilter.fields,null!==(t=this.searchFilter.query)&&void 0!==t?t:void 0),this.userIdsFilter&&n.setUserIdsFilter(this.userIdsFilter.userIds,this.userIdsFilter.includeMode,this.userIdsFilter.queryType);var r=JSON.parse(JSON.stringify(this));return Object.keys(r).forEach((function(e){n[e]=r[e]})),n},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 Wt.CHANNEL_NAME:return e.name.toLowerCase().includes(r.toLowerCase());case Wt.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 Bt.AND:if(a.some((function(e){return!c.includes(e)})))return!1;break;case Bt.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(!d(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 h=this.nicknameStartsWithFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase().startsWith(h)})))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 Ot.JOINED:if("joined"!==e.myMemberState)return!1;break;case Ot.INVITED:if("invited"!==e.myMemberState)return!1;break;case Ot.INVITED_BY_FRIEND:if("invited"!==e.myMemberState||!this._isFriend(e.inviter))return!1;break;case Ot.INVITED_BY_NON_FRIEND:if("invited"!==e.myMemberState||this._isFriend(e.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case Vt.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case Vt.HIDDEN:if(!e.isHidden)return!1;break;case Vt.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case Vt.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===Gt.UNREAD_MESSAGE)if(0===e.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case xt.PUBLIC:if(!e.isPublic)return!1;break;case xt.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case Ht.SUPER:if(!e.isSuper)return!1;break;case Ht.NON_SUPER:if(e.isSuper)return!1}return!0},e}(),Yt=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 f(!!e).throw(_.databaseError),e.collection(ge)},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),i(i({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})},n.prototype._deserialize=function(e){return rr.of(this._iid).buildGroupChannelFromSerializedData(e)},Object.defineProperty(n.prototype,"channels",{get:function(){return m([],v(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(l&&l===e.url)return!1;break;case Ge.CHRONOLOGICAL:if(!i&&e.createdAt>t||i&&e.createdAtt||i&&e.lastMessageUpdatedAt0?[4,this.upsert(r)]:[3,2];case 1:y.sent(),y.label=2;case 2:return[2]}}))}))},n.prototype.block=function(e,t){return g(this,void 0,void 0,(function(){return y(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 g(this,void 0,void 0,(function(){return y(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=m([],v(this._channels.keys()),!1)),g(this,void 0,void 0,(function(){var n,r,s,i,a,o,u,c;return y(this,(function(l){switch(l.label){case 0:n=[],l.label=1;case 1:l.trys.push([1,6,7,8]),r=C(t),s=r.next(),l.label=2;case 2:return s.done?[3,5]:(i=s.value,[4,this.get(i)]);case 3:(null==(a=l.sent())?void 0:a._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}(h),Jt={invitedUserIds:void 0,channelUrl:void 0,coverUrl:void 0,coverImage:void 0,isDistinct:void 0,isSuper:void 0,isBroadcast:void 0,isExclusive:void 0,isPublic:void 0,isDiscoverable:void 0,isStrict:void 0,isEphemeral:void 0,accessCode:void 0,name:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,messageSurvivalSeconds:void 0},Xt=function(e){return E("string",e.invitedUserIds,!0)&&b("string",e.channelUrl,!0)&&b("string",e.coverUrl,!0)&&(M(e.coverImage)||b("string",e.coverImage,!0))&&b("boolean",e.isDistinct,!0)&&b("boolean",e.isSuper,!0)&&b("boolean",e.isBroadcast,!0)&&b("boolean",e.isExclusive,!0)&&b("boolean",e.isPublic,!0)&&b("boolean",e.isStrict,!0)&&b("boolean",e.isDiscoverable,!0)&&b("boolean",e.isEphemeral,!0)&&b("string",e.accessCode,!0)&&b("string",e.name,!0)&&b("string",e.data,!0)&&b("string",e.customType,!0)&&E("string",e.operatorUserIds,!0)&&b("number",e.messageSurvivalSeconds,!0)},Zt={customTypes:void 0,includeEmpty:!1,includeFrozen:!0},$t=function(e){return E("string",e.customTypes,!0)&&b("boolean",e.includeEmpty)&&b("boolean",e.includeFrozen)},en={myMemberStateFilter:Ot.ALL},tn=function(e){return a(Ot,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 nn={keys:[]},rn={channelCustomTypesFilter:void 0,superChannelFilter:Ht.ALL},sn={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:N.ALL},an=function(){function e(e){var t=e.groupChannelCache,n=e.messageCache,r=e.unsentMessageCache,s=e.dispatcher,i=this;this._observers=new Map,s.on((function(e){return g(i,void 0,void 0,(function(){var s,i,a,o,u,c,l,h,d,p,f,_,m,v,E=this;return y(this,(function(b){switch(b.label){case 0:if(!(e instanceof We))return[3,10];s=e.channels,f=e.source,_=e.isWebSocketEventComing,i=e.data,a=s.filter((function(e){return e instanceof cs})),o=t.filterOffsetChanged(a),b.label=1;case 1:b.trys.push([1,6,7,8]),u=C(o),c=u.next(),b.label=2;case 2:return c.done?[3,5]:(l=c.value,[4,n.removeUnderOffset(l.url,l.messageOffsetTimestamp)]);case 3:b.sent(),b.label=4;case 4:return c=u.next(),[3,2];case 5:return[3,8];case 6:return h=b.sent(),m={error:h},[3,8];case 7:try{c&&!c.done&&(v=u.return)&&v.call(u)}finally{if(m)throw m.error}return[7];case 8:return[4,t.upsert(a)];case 9:return d=b.sent(),_||this._broadcastUpdateEvent(d,f,i),[3,15];case 10:return e instanceof Be?(p=e.channelUrls,f=e.source,_=e.isWebSocketEventComing,[4,t.remove(p)]):[3,13];case 11:return b.sent(),[4,U((function(){return g(E,void 0,void 0,(function(){var e,t,s,i,a,o;return y(this,(function(u){switch(u.label){case 0:u.trys.push([0,6,7,8]),e=C(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 b.sent(),_||this._broadcastRemoveEvent(p,f),[3,15];case 13:return e instanceof qe?[4,t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER})]:[3,15];case 14:b.sent(),b.label=15;case 15:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t,n){var r,s;try{for(var i=C(this._observers.values()),a=i.next();!a.done;a=i.next()){var o=a.value;o.onUpdate&&o.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=C(this._observers.values()),i=s.next();!i.done;i=s.next()){var a=i.value;a.onRemove&&a.onRemove(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype.subscribe=function(e,t){this._observers.set(e,t)},e.prototype.unsubscribe=function(e){this._observers.delete(e)},e.prototype.unsubscribeAll=function(){this._observers.clear()},e}(),on=function(){function e(e){var t=e.cacheContext,n=e.messageCache,r=e.unsentMessageCache,s=e.dispatcher,i=e.logger,a=this;this._observers=new Map,this._cacheContext=t,this._logger=i,s.on((function(e){return g(a,void 0,void 0,(function(){var t,s,i,a,o,u,c,l,h,d,p,f,_,m,v=this;return y(this,(function(C){switch(C.label){case 0:return e instanceof L?(t=e.messages,_=e.source,o=e.isWebSocketEventComing,s=t.filter((function(e){return e.messageId>0})),i=t.filter((function(e){return 0===e.messageId})),s.length>0?[4,U((function(){return g(v,void 0,void 0,(function(){return y(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 Ct?e.reqId:null})).filter((function(e){return null!==e})))];case 2:return e.sent(),[2]}}))}))}))]:[3,2]):[3,5];case 1:C.sent(),o||this._broadcastUpdateEvent(s,_),C.label=2;case 2:return i.length>0?[4,U((function(){return g(v,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,r.upsert(i)];case 1:return e.sent(),[2]}}))}))}))]:[3,4];case 3:C.sent(),o||this._broadcastUpdateEvent(i,_),C.label=4;case 4:return[3,21];case 5:return e instanceof w?(a=e.messageIds,_=e.source,o=e.isWebSocketEventComing,[4,U((function(){return g(v,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,n.remove(a)];case 1:return e.sent(),[2]}}))}))}))]):[3,7];case 6:return C.sent(),o||this._broadcastRemoveEvent(a,_),[3,21];case 7:return e instanceof I?(u=e.reqId,_=e.source,[4,U((function(){return g(v,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,r.remove([u])];case 1:return e.sent(),[2]}}))}))}))]):[3,9];case 8:return C.sent(),this._broadcastRemoveUnsentEvent(u,_),[3,21];case 9:return e instanceof A?(c=e.polls,_=e.source,this._cacheContext.localCacheEnabled?(l=c.map((function(e){return e.messageId})),[4,Promise.all(l.map((function(e){return n.get(e)})))]):[3,12]):[3,13];case 10:return(h=C.sent().filter((function(e){return e}))).length>0&&c.forEach((function(e){var t=h.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),[4,U((function(){return g(v,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,n.upsert(h)];case 1:return[2,e.sent()]}}))}))}))];case 11:C.sent(),C.label=12;case 12:return this._broadcastPollChangeLogEvent(c,_),[3,21];case 13:return e instanceof T?(d=e.event,_=e.source,[4,n.get(d.messageId)]):[3,17];case 14:return(p=C.sent())&&p.isUserMessage()&&p.poll&&p.poll.applyPollUpdateEvent(d)?[4,U((function(){return g(v,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,n.upsert([p])];case 1:return[2,e.sent()]}}))}))}))]:[3,16];case 15:C.sent(),C.label=16;case 16:return this._broadcastPollUpdateEvent(d,_),[3,21];case 17:return e instanceof S?(f=e.event,_=e.source,[4,n.get(f.messageId)]):[3,21];case 18:return(m=C.sent())&&m.isUserMessage()&&m.poll&&m.poll.applyPollVoteEvent(f)?[4,U((function(){return g(v,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,n.upsert([m])];case 1:return[2,e.sent()]}}))}))}))]:[3,20];case 19:C.sent(),C.label=20;case 20:this._broadcastPollVoteEvent(f,_),C.label=21;case 21:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var s=C(this._observers.values()),i=s.next();!i.done;i=s.next()){var a=i.value;a.onUpdate&&a.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=C(this._observers.values()),i=s.next();!i.done;i=s.next()){var a=i.value;a.onPollChangeLogUpdate&&a.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=C(this._observers.values()),i=s.next();!i.done;i=s.next()){var a=i.value;a.onPollUpdate&&a.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=C(this._observers.values()),i=s.next();!i.done;i=s.next()){var a=i.value;a.onPollVote&&a.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=C(this._observers.values()),i=s.next();!i.done;i=s.next()){var a=i.value;a.onRemove&&a.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=C(this._observers.values()),i=s.next();!i.done;i=s.next()){var a=i.value;a.onRemoveUnsent&&a.onRemoveUnsent(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype.subscribe=function(e,t){this._observers.set(e,t)},e.prototype.unsubscribe=function(e){this._observers.delete(e)},e.prototype.unsubscribeAll=function(){this._observers.clear()},e}(),un=function(t){function n(e){var n=e.userId,a=e.ts,o=e.token,u=e.filter,c=t.call(this)||this,l=i(i({},Zt),u),h=l.customTypes,d=l.includeEmpty,p=l.includeFrozen;return c.method=D.GET,c.path="".concat(k,"/").concat(encodeURIComponent(n),"/my_group_channels/changelogs"),c.params=r(s({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:a||null,token:o,custom_types:h,show_empty:d,show_frozen:p})),c}return e(n,t),n}(R),cn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.updatedChannels=n.updated.map((function(t){return new cs(e,t)})),r.deletedChannelUrls=n.deleted,r.hasMore=n.has_more,r.token=n.next,r}return e(n,t),n}(F),ln=function(t){function n(e){var n=e.channelUrl,r=e.isInternalCall,s=t.call(this)||this;return s.method=D.GET,s.path="".concat(r?x:O,"/").concat(encodeURIComponent(n)),s.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},s}return e(n,t),n}(R),hn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new cs(e,n),r}return e(n,t),n}(F),dn={includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,channelUrlsFilter:void 0,customTypesFilter:void 0,customTypeStartsWithFilter:void 0,nicknameContainsFilter:void 0,nicknameStartsWithFilter:void 0,nicknameExactMatchFilter:void 0,channelNameContainsFilter:void 0,myMemberStateFilter:Ot.ALL,unreadChannelFilter:Gt.ALL,superChannelFilter:Ht.ALL,publicChannelFilter:xt.ALL,hiddenChannelFilter:Vt.ALL,userIdsFilter:{userIds:[],includeMode:!0,queryType:Bt.AND},searchFilter:{query:void 0,fields:[]},metadataKey:void 0,metadataValues:void 0,metadataOrderKeyFilter:void 0,metadataValueStartsWith:void 0,order:Ge.LATEST_LAST_MESSAGE},pn=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,U=e.includeFrozen,S=e.includeMetaData,T=e.searchFilter,A=e.userIdsFilter;return(n=t.call(this)||this).method=D.GET,n.path="".concat(k,"/").concat(encodeURIComponent(s),"/my_group_channels"),n.params=r({token:i,limit:a,order:null!=o?o:dn.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=u?u:dn.includeEmpty,member_state_filter:null!=c?c:dn.myMemberStateFilter,super_mode:null!=l?l:dn.superChannelFilter,public_mode:null!=h?h:dn.publicChannelFilter,unread_filter:null!=d?d:dn.unreadChannelFilter,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:U,show_metadata:S}),T&&T.query&&T.fields&&(n.params.search_query=T.query,n.params.search_fields=T.fields),A&&A.userIds&&A.userIds.length>0&&(A.includeMode?(n.params.members_include_in=A.userIds,n.params.query_type=A.queryType.toUpperCase()):n.params.members_exactly_in=A.userIds),n}return e(n,t),n}(R),fn=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.channels=[];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 cs(e,t)}))),r.ts=null!=a?a:0,r}return e(n,t),n}(F),_n=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.myMemberStateFilter;return s.method=D.GET,s.path="".concat(k,"/").concat(encodeURIComponent(n),"/group_channel_count"),s.params={state:null!=i?i:Ot.ALL},s}return e(n,t),n}(R),mn=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}(F),vn=function(t){function n(e){var n=e.userId,s=e.filter,i=t.call(this)||this,a=s.keys;return i.method=D.GET,i.path="".concat(k,"/").concat(encodeURIComponent(n),"/unread_item_count"),i.params=r({item_keys:a}),i}return e(n,t),n}(R),gn=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}(F),yn=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=D.GET,r.path="".concat(k,"/").concat(encodeURIComponent(n),"/unread_channel_count"),r}return e(n,t),n}(R),Cn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.unreadCount=n.unread_count,r}return e(n,t),n}(F),En=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=D.GET,s.path="".concat(k,"/").concat(encodeURIComponent(n),"/unread_message_count"),s.params={super_mode:null!=a?a:Ht.ALL,custom_types:i},s}return e(n,t),n}(R),bn=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}(F),Mn=function(t){function n(e){var n=e.channelUrl,r=e.scheduledStatus,s=e.messageTypeFilter,i=t.call(this)||this;return i.method=D.GET,i.path="".concat(H,"/count"),i.params={channel_url:n,status:Un(r)},s&&(i.params.message_type=s),i}return e(n,t),n}(R),Nn=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}(F),Un=function(e){if(!e)return[];var t=[];return e.forEach((function(e){switch(e){case yt.PENDING:t.push(Et.PENDING);break;case yt.SENT:t.push(Et.IN_QUEUE),t.push(Et.SENT);break;case yt.CANCELED:t.push(Et.CANCELED);break;case yt.FAILED:t.push(Et.FAILED)}})),t},Sn=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,d=e.isExclusive,p=e.isDiscoverable,f=e.isStrict,_=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=D.POST,n.path=O,n.params=r({user_ids:m([s],v(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:d,is_public:h,is_discoverable:p,strict:f,is_ephemeral:_,access_code:g,name:y,data:C,custom_type:E,operator_ids:N,message_survival_seconds:b}),n}return e(n,t),n}(R),Tn=function(t){function n(e,n){var r,s=this;return(s=t.call(this,e,n)||this).channel=new cs(e,n),s.isCreated=null===(r=n.is_created)||void 0===r||r,s}return e(n,t),n}(F),An=function(t){function n(e){var n=e.userId,r=e.channelUrls,s=t.call(this)||this;return s.method=D.PUT,s.path="".concat(k,"/").concat(encodeURIComponent(n),"/mark_as_read_all"),s.params={channel_urls:r},s}return e(n,t),n}(R);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(F);var In=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.accessCode;return(n=t.call(this)||this).method=D.PUT,n.path="".concat(O,"/").concat(encodeURIComponent(r),"/join"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(R),wn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new cs(e,n),r}return e(n,t),n}(F),Ln=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,a=i.member_count,o=void 0===a?0:a,u=i.joined_member_count,c=void 0===u?0: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 zt(e,t)})):[new zt(e,r.data)],s}return e(n,t),n}(ct),Dn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.shouldRemoveOperatorStatus;return(n=t.call(this)||this).method=D.PUT,n.path="".concat(O,"/").concat(encodeURIComponent(r),"/leave"),n.params={user_id:s,should_remove_operator_status:i},n}return e(n,t),n}(R);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(F);var kn=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,a=i.member_count,o=void 0===a?0:a,u=i.joined_member_count,c=void 0===u?0:u;return s.memberCount=o,s.joinedMemberCount=c,s.member=new zt(s._iid,r.data),s}return e(n,t),n}(ct),Pn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userIds;return(n=t.call(this)||this).method=D.POST,n.path="".concat(O,"/").concat(encodeURIComponent(r),"/invite"),n.params={user_ids:s},n}return e(n,t),n}(R),Rn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new cs(e,n),r}return e(n,t),n}(F),Fn=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?0:a,u=i.joined_member_count,l=void 0===u?0:u,h=i.inviter,d=i.invitees,p=void 0===d?[]:d;return s.memberCount=o,s.joinedMemberCount=l,s.inviter=new c(e,h),s.invitees=p.map((function(t){return new zt(e,t)})),s}return e(n,t),n}(ct),xn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId;return(n=t.call(this)||this).method=D.PUT,n.path="".concat(O,"/").concat(encodeURIComponent(r),"/decline"),n.params={user_id:s},n}return e(n,t),n}(R);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new cs(e,n),r.channel.myMemberState=Ft.NONE,r}e(n,t)}(F);var On=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,a=i.member_count,o=i.joined_member_count,u=i.inviter,l=i.invitee;return s.memberCount=null!=a?a:0,s.joinedMemberCount=null!=o?o:0,s.inviter=new c(e,u),s.invitee=new zt(e,l),s}return e(n,t),n}(ct),Hn=function(t){function n(e){var n=e.channelUrl;return t.call(this,{code:"READ",ackRequired:!0,payload:{channel_url:n}})||this}return e(n,t),n}(V),Gn=function(t){function n(e,n,r){var s=t.call(this,e,"READ",r)||this;return s.readStatus=new jt(e,r),s}return e(n,t),n}(q),Vn=function(t){function n(e){var n=e.channelUrl,s=e.userId,i=t.call(this)||this;return(i=t.call(this)||this).method=D.PUT,i.path="".concat(O,"/").concat(encodeURIComponent(n),"/messages/mark_as_delivered"),i.params=r({userId:s}),i}return e(n,t),n}(R);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(F);var qn,Bn=function(t){function n(e,n,r){var s=t.call(this,e,"DLVR",r)||this;return s.channelUrl=r.channel_url,s.deliveredStateUpdate=r.updated,s}return e(n,t),n}(q),Wn={hidePreviousMessages:!1,allowAutoUnhide:!0},zn=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=D.PUT,n.path="".concat(O,"/").concat(encodeURIComponent(r),"/hide"),n.params={user_id:s,hide_previous_messages:null!=i?i:Wn.hidePreviousMessages,allow_auto_unhide:null!=a?a:Wn.allowAutoUnhide},n}return e(n,t),n}(R),jn=function(t){function n(e,n){var r=t.call(this,e,n)||this,s=n.ts_message_offset;return r.messageOffsetTimestamp=s,r}return e(n,t),n}(F),Qn=function(t){function n(e,n,r){var s,i,a,o=this;return(o=t.call(this,e,"SYEV",r)||this).allowAutoUnhide=null,o.hidePreviousMessages=null,o.messageOffsetTimestamp=null,r.data&&(o.allowAutoUnhide=null!==(s=r.data.allow_auto_unhide)&&void 0!==s?s:null,o.hidePreviousMessages=null!==(i=r.data.hide_previous_messages)&&void 0!==i?i:null),o.messageOffsetTimestamp=null!==(a=r.ts_message_offset)&&void 0!==a?a:null,o}return e(n,t),n}(q),Kn=function(t){function n(e){var n=e.channelUrl,r=e.time;return t.call(this,{code:"TPST",ackRequired:!1,payload:{channel_url:n,time:r}})||this}return e(n,t),n}(V),Yn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.user=new c(e,r.data),s}return e(n,t),n}(q),Jn=function(t){function n(e){var n=e.channelUrl,r=e.time;return t.call(this,{code:"TPEN",ackRequired:!1,payload:{channel_url:n,time:r}})||this}return e(n,t),n}(V),Xn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.user=new c(e,r.data),s}return e(n,t),n}(q),Zn=function(t){function n(e){var n=e.channelUrl,r=e.messageId;return t.call(this,{code:"MACK",ackRequired:!1,payload:{channel_url:n,msg_id:r}})||this}return e(n,t),n}(V),$n=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,U=this;return(U=t.call(this,e,n)||this).includeEmpty=!1,U.includeFrozen=!0,U.includeMetaData=!0,U.channelUrlsFilter=null,U.customTypesFilter=null,U.customTypeStartsWithFilter=null,U.nicknameContainsFilter=null,U.nicknameStartsWithFilter=null,U.nicknameExactMatchFilter=null,U.channelNameContainsFilter="",U.myMemberStateFilter=Ot.ALL,U.unreadChannelFilter=Gt.ALL,U.superChannelFilter=Ht.ALL,U.publicChannelFilter=xt.ALL,U.hiddenChannelFilter=Vt.UNHIDDEN,U.searchFilter={fields:[],query:null},U.userIdsFilter={userIds:[],includeMode:!0,queryType:Bt.AND},U.metadataKey=null,U.metadataValues=null,U.metadataOrderKeyFilter=null,U.metadataValueStartsWith=null,U.order=Ge.LATEST_LAST_MESSAGE,U.includeEmpty=null!==(r=n.includeEmpty)&&void 0!==r&&r,U.includeFrozen=null===(s=n.includeFrozen)||void 0===s||s,U.includeMetaData=null===(i=n.includeMetaData)||void 0===i||i,U.channelUrlsFilter=null!==(a=n.channelUrlsFilter)&&void 0!==a?a:null,U.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,U.customTypeStartsWithFilter=null!==(u=n.customTypeStartsWithFilter)&&void 0!==u?u:"",U.nicknameContainsFilter=null!==(c=n.nicknameContainsFilter)&&void 0!==c?c:null,U.nicknameStartsWithFilter=null!==(l=n.nicknameStartsWithFilter)&&void 0!==l?l:null,U.nicknameExactMatchFilter=null!==(h=n.nicknameExactMatchFilter)&&void 0!==h?h:null,U.channelNameContainsFilter=null!==(d=n.channelNameContainsFilter)&&void 0!==d?d:"",U.myMemberStateFilter=null!==(p=n.myMemberStateFilter)&&void 0!==p?p:Ot.ALL,U.unreadChannelFilter=null!==(f=n.unreadChannelFilter)&&void 0!==f?f:Gt.ALL,U.superChannelFilter=null!==(_=n.superChannelFilter)&&void 0!==_?_:Ht.ALL,U.publicChannelFilter=null!==(m=n.publicChannelFilter)&&void 0!==m?m:xt.ALL,U.hiddenChannelFilter=null!==(v=n.hiddenChannelFilter)&&void 0!==v?v:Vt.UNHIDDEN,U.searchFilter=null!==(g=n.searchFilter)&&void 0!==g?g:{fields:[],query:null},U.userIdsFilter=null!==(y=n.userIdsFilter)&&void 0!==y?y:{userIds:[],includeMode:!0,queryType:Bt.AND},U.metadataKey=null!==(C=n.metadataKey)&&void 0!==C?C:null,U.metadataValues=null!==(E=n.metadataValues)&&void 0!==E?E:null,U.metadataOrderKeyFilter=null!==(b=n.metadataOrderKeyFilter)&&void 0!==b?b:null,U.metadataValueStartsWith=null!==(M=n.metadataValueStartsWith)&&void 0!==M?M:null,U.order=null!==(N=n.order)&&void 0!==N?N:Ge.LATEST_LAST_MESSAGE,U}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&b("boolean",this.includeEmpty)&&b("boolean",this.includeFrozen)&&b("boolean",this.includeMetaData)&&b("string",this.channelNameContainsFilter)&&E("string",this.channelUrlsFilter,!0)&&E("string",this.customTypesFilter,!0)&&b("string",this.customTypeStartsWithFilter)&&b("string",this.nicknameContainsFilter,!0)&&b("string",this.nicknameStartsWithFilter,!0)&&b("string",this.nicknameExactMatchFilter,!0)&&a(Ot,this.myMemberStateFilter)&&a(Ht,this.superChannelFilter)&&a(xt,this.publicChannelFilter)&&a(Gt,this.unreadChannelFilter)&&a(Vt,this.hiddenChannelFilter)&&E(Wt,this.searchFilter.fields)&&b("string",this.searchFilter.query,!0)&&E("string",this.userIdsFilter.userIds)&&b("boolean",this.userIdsFilter.includeMode)&&a(Bt,this.userIdsFilter.queryType)&&a(Ge,this.order)&&b("string",this.metadataOrderKeyFilter,!0)&&b("string",this.metadataKey,!0)&&E("string",this.metadataValues,!0)&&b("string",this.metadataValueStartsWith,!0)},n.prototype.serialize=function(){return B(this)},n.prototype.next=function(){return g(this,void 0,void 0,(function(){var e,t,n;return y(this,(function(r){switch(r.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,rr.of(this._iid).getMyGroupChannels(this._token,s(i({},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 _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},n}(W),er=function(){function e(e){var t=e.top,n=void 0===t?Number.MAX_SAFE_INTEGER:t,r=e.bottom,s=void 0===r?0:r;this.top=n,this.bottom=s}return e.prototype.includes=function(){for(var e=this,t=[],n=0;n0||D.unreadMentionCount>0)&&(D._updateUnreadCount(0,0),this._dispatcher.dispatch(new We({channels:[D],source:ze.EVENT_CHANNEL_READ})),Y((function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(D)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))):0!==D.unreadMessageCount&&0!==D.unreadMentionCount||(this._dispatcher.dispatch(new We({channels:[D],source:ze.EVENT_CHANNEL_READ})),Y((function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(D)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))):(this._dispatcher.dispatch(new We({channels:[D],source:ze.EVENT_CHANNEL_READ})),Y((function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onUnreadMemberStatusUpdated&&n.onUnreadMemberStatusUpdated(D)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))),Un.label=12;case 12:return[3,79];case 13:return k=e.as(Bn),le=k.channelUrl,P=k.deliveredStateUpdate,R=void 0===P?{}:P,F=this._groupChannelCache.isCachedInMemory(le),[4,this.getChannel(le,!0)];case 14:if(x=Un.sent(),F)for(O in R)x._updateUndeliveredMemberState(O,R[O]);return Object.keys(R).some((function(e){return e!==Nn._sdkState.userId}))&&(this._dispatcher.dispatch(new We({channels:[x],source:ze.EVENT_CHANNEL_DELIVERED})),Y((function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onUndeliveredMemberStatusUpdated&&n.onUndeliveredMemberStatusUpdated(x)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))),[3,79];case 15:return H=e.as(_t),le=H.channelUrl,he=H.channelType,G=H.event,he!==u.GROUP?[3,18]:[4,this.getChannel(le,!0)];case 16:return V=Un.sent(),[4,this.getMessageFromCache(G.messageId)];case 17:(W=Un.sent())&&(W.applyReactionEvent(G),this._dispatcher.dispatch(new L({messages:[W],source:J.EVENT_MESSAGE_REACTION_UPDATED}))),Y((function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onReactionUpdated&&n.onReactionUpdated(V,G)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))})),Un.label=18;case 18:return[3,79];case 19:return(q=e.as(ft).event).channelType!==u.GROUP?[3,22]:[4,this.getChannel(q.channelUrl,!0)];case 20:return B=Un.sent(),[4,this.getMessageFromCache(q.targetMessageId)];case 21:(W=Un.sent())&&(W.applyThreadInfoUpdateEvent(q),this._dispatcher.dispatch(new L({messages:[W],source:J.EVENT_MESSAGE_THREADINFO_UPDATED}))),Y((function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onThreadInfoUpdated&&n.onThreadInfoUpdated(B,q)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))})),Un.label=22;case 22:return[3,79];case 23:z=e.as(pt).groupChannelMemberCounts,Q=[],Un.label=24;case 24:Un.trys.push([24,29,30,31]),X=C(z),$=X.next(),Un.label=25;case 25:return $.done?[3,28]:(ee=$.value,le=ee.channelUrl,it=ee.memberCount,at=ee.joinedMemberCount,te=ee.updatedAt,[4,this.getChannelFromCache(le)]);case 26:(ne=Un.sent())&&ne._setLatestMemberCount(it,at,te)&&Q.push(ne),Un.label=27;case 27:return $=X.next(),[3,25];case 28:return[3,31];case 29:return re=Un.sent(),mn={error:re},[3,31];case 30:try{$&&!$.done&&(vn=X.return)&&vn.call(X)}finally{if(mn)throw mn.error}return[7];case 31:return Q.length>0&&(this._dispatcher.dispatch(new We({channels:Q,source:ze.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),Y((function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelMemberCountChanged&&n.onChannelMemberCountChanged(Q)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))),[3,79];case 32:return se=e.as(dt),ie=se.event,ae=se.status,le=se.channelUrl,he=se.channelType,le&&he===u.GROUP?[4,this.getChannel(le,!0)]:[3,34];case 33:oe=Un.sent(),this._dispatcher.dispatch(new T({event:ie,source:J.EVENT_POLL_UPDATED})),Y(ae===Z?function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollDeleted&&n.onPollDeleted(oe,ie.pollId)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))}:function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollUpdated&&n.onPollUpdated(oe,ie)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))}),Un.label=34;case 34:return[3,79];case 35:return ue=e.as(Te),ce=ue.event,le=ue.channelUrl,he=ue.channelType,le&&he===u.GROUP?[4,this.getChannel(le,!0)]:[3,37];case 36:de=Un.sent(),this._dispatcher.dispatch(new S({event:ce,source:J.EVENT_POLL_VOTED})),Y((function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollVoted&&n.onPollVoted(de,ce)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))})),Un.label=37;case 37:return[3,79];case 38:if(!(pe=e.as(ct).event).isGroupChannelEvent)return[3,77];switch(pe.category){case lt.CHANNEL_JOIN:return[3,39];case lt.CHANNEL_LEAVE:return[3,41];case lt.CHANNEL_OPERATOR_UPDATE:return[3,45];case lt.CHANNEL_INVITE:return[3,47];case lt.CHANNEL_DECLINE_INVITE:return[3,49];case lt.TYPING_START:case lt.TYPING_END:return[3,51];case lt.USER_CHANNEL_MUTE:case lt.USER_CHANNEL_UNMUTE:return[3,53];case lt.USER_CHANNEL_BAN:return[3,55];case lt.USER_CHANNEL_UNBAN:return[3,59];case lt.CHANNEL_FREEZE:case lt.CHANNEL_UNFREEZE:return[3,61];case lt.CHANNEL_HIDE:return[3,63];case lt.CHANNEL_UNHIDE:return[3,65];case lt.CHANNEL_DELETED:return[3,67];case lt.CHANNEL_PROP_CHANGED:return[3,69];case lt.CHANNEL_META_DATA_CHANGED:return[3,71];case lt.CHANNEL_META_COUNTERS_CHANGED:return[3,73];case lt.PINNED_MESSAGE_CHANGED:return[3,75]}return[3,77];case 39:return[4,this.getChannel(pe.channelUrl,!0)];case 40:return fe=Un.sent(),_e=e.as(Ln),me=_e.memberCount,ve=_e.joinedMemberCount,ge=_e.members,ye=!1,ge.forEach((function(e){fe.isExclusive||fe.isSuper||fe.isBroadcast?ye=ye||fe._setLatestMemberCount(me,ve,pe.ts):(e.state=Ft.JOINED,fe.addMember(e,pe.ts),Nn._updateJoinedMemberCount(fe)),e.userId===Nn._sdkState.userId&&(fe.myMemberState=Ft.JOINED)})),this._dispatcher.dispatch(new We({channels:[fe],source:ze.EVENT_CHANNEL_JOINED})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){var t,n;try{for(var r=C(ge),s=r.next();!s.done;s=r.next()){var i=s.value;e.onUserJoined&&e.onUserJoined(fe,i)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}fe.isBroadcast&&ye&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([fe])})),[2]}))}))})),[3,77];case 41:return(It=this._leftChannels.get(pe.channelUrl))?(ke=It.channel,[3,44]):[3,42];case 42:return[4,this.getChannel(pe.channelUrl,!0)];case 43:ke=Un.sent(),Un.label=44;case 44:return De=ke,Pe=e.as(kn),it=Pe.memberCount,at=Pe.joinedMemberCount,Re=Pe.member,Fe=!1,xe=j.of(this._iid).appInfo,De.isExclusive||De.isSuper||De.isBroadcast?Fe=De._setLatestMemberCount(it,at,pe.ts):((null==xe?void 0:xe.enabledChannelMemberShipHistory)?((Oe=De.members.find((function(e){return e.userId===Oe.userId})))&&(Oe.state=Ft.LEFT),De.memberCount=it):De.removeMember(Re),this._updateJoinedMemberCount(De)),Re.userId===this._sdkState.userId?(De.myMemberState=Ft.NONE,De.invitedAt=0,De.joinedAt=0,De._updateUnreadCount(0,0),De.isPublic?this._dispatcher.dispatch(new We({channels:[De],source:ze.EVENT_CHANNEL_LEFT})):(this._markAsLeave(De),this._dispatcher.dispatch(new Be({channelUrls:[De.url],source:ze.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new We({channels:[De],source:ze.EVENT_CHANNEL_LEFT})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserLeft&&e.onUserLeft(De,Re),De.isBroadcast&&Fe&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([De])})),[2]}))}))})),[3,77];case 45:return[4,this.getChannel(pe.channelUrl,!0)];case 46:He=Un.sent(),Ge=e.as(ht).operators,Ve=Ge.map((function(e){return e.userId}));try{for(qe=C(He.members),je=qe.next();!je.done;je=qe.next())(At=je.value).role=Ve.includes(At.userId)?o.OPERATOR:o.NONE}catch(e){gn={error:e}}finally{try{je&&!je.done&&(yn=qe.return)&&yn.call(qe)}finally{if(gn)throw gn.error}}return He.myRole=Ve.includes(this._sdkState.userId)?o.OPERATOR:o.NONE,this._dispatcher.dispatch(new We({channels:[He],source:ze.EVENT_CHANNEL_OPERATOR_UPDATED})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(He,Ge)})),[2]}))}))})),[3,77];case 47:return[4,this.getChannel(pe.channelUrl,!0)];case 48:Qe=Un.sent(),Ke=e.as(Fn),it=Ke.memberCount,at=Ke.joinedMemberCount,Ye=Ke.inviter,(Je=Ke.invitees).forEach((function(e){return e.state=Ft.INVITED}));try{for(Xe=C(Je),tt=Xe.next();!tt.done;tt=Xe.next())nt=tt.value,Qe.isExclusive||Qe.isSuper||Qe.isBroadcast?Qe._setLatestMemberCount(it,at,pe.ts):Qe.addMember(nt,pe.ts),this._sdkState.userId===nt.userId&&(Qe.hiddenState=rs.UNHIDDEN,Qe.myMemberState!==Ft.JOINED&&(Qe.myMemberState=Ft.INVITED),Qe.invitedAt=pe.ts)}catch(e){Cn={error:e}}finally{try{tt&&!tt.done&&(En=Xe.return)&&En.call(Xe)}finally{if(Cn)throw Cn.error}}return this._dispatcher.dispatch(new We({channels:[Qe],source:ze.EVENT_CHANNEL_INVITED})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation&&e.onUserReceivedInvitation(Qe,Ye,Je)})),[2]}))}))})),[3,77];case 49:return[4,this.getChannel(pe.channelUrl,!0)];case 50:return rt=Un.sent(),st=e.as(On),it=st.memberCount,at=st.joinedMemberCount,ot=st.inviter,ut=st.invitee,rt.isExclusive||rt.isSuper||rt.isBroadcast?rt._setLatestMemberCount(it,at,pe.ts):rt.removeMember(ut),this._sdkState.userId===ut.userId?(rt.invitedAt=0,rt.myMemberState=Ft.NONE,rt.isPublic?this._dispatcher.dispatch(new We({channels:[rt],source:ze.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new Be({channelUrls:[rt.url],source:ze.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new We({channels:[rt],source:ze.EVENT_CHANNEL_DECLINED_INVITE})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(rt,ot,ut)})),[2]}))}))})),[3,77];case 51:return[4,this.getChannel(pe.channelUrl,!0)];case 52:return gt=Un.sent(),yt=pe.category===lt.TYPING_START,Et=e.as(yt?Yn:Xn).user,gt._updateTypingStatus(Et,yt?pe.ts:0),this._dispatcher.dispatch(new We({channels:[gt],source:ze.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated&&e.onTypingStatusUpdated(gt)})),[2]}))}))})),[3,77];case 53:return[4,this.getChannel(pe.channelUrl,!0)];case 54:bt=Un.sent(),Mt=pe.category===lt.USER_CHANNEL_MUTE,(Nt=e.as(Mt?Ue:Se).user).userId===this._sdkState.userId&&(bt.myMutedState=Mt?ns.MUTED:ns.UNMUTED,bt._myMutedRemainingTime=Nt.restrictionInfo.remainingDuration);try{for(St=C(bt.members),Tt=St.next();!Tt.done;Tt=St.next())if((At=Tt.value).userId===Nt.userId){At.isMuted=Mt;break}}catch(e){bn={error:e}}finally{try{Tt&&!Tt.done&&(Mn=St.return)&&Mn.call(St)}finally{if(bn)throw bn.error}}return this._dispatcher.dispatch(new We({channels:[bt],source:Mt?ze.EVENT_CHANNEL_MUTED:ze.EVENT_CHANNEL_UNMUTED,data:Nt.userId})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Mt?e.onUserMuted&&e.onUserMuted(bt,Nt):e.onUserUnmuted&&e.onUserUnmuted(bt,Nt)})),[2]}))}))})),[3,77];case 55:return(It=this._leftChannels.get(pe.channelUrl))?(Lt=It.channel,[3,58]):[3,56];case 56:return[4,this.getChannel(pe.channelUrl,!0)];case 57:Lt=Un.sent(),Un.label=58;case 58:return wt=Lt,this._markAsLeave(wt),Dt=e.as(Ne).user,Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserBanned&&e.onUserBanned(wt,Dt)})),[2]}))}))})),[3,77];case 59:return[4,this.getChannel(pe.channelUrl,!0)];case 60:return kt=Un.sent(),Pt=e.as(Me).user,Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned&&e.onUserUnbanned(kt,Pt)})),[2]}))}))})),[3,77];case 61:return[4,this.getChannel(pe.channelUrl,!0)];case 62:return Rt=Un.sent(),xt=e.as(be).freeze,Rt.isFrozen=xt,this._dispatcher.dispatch(new We({channels:[Rt],source:xt?ze.EVENT_CHANNEL_FROZEN:ze.EVENT_CHANNEL_UNFROZEN})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){xt?e.onChannelFrozen&&e.onChannelFrozen(Rt):e.onChannelUnfrozen&&e.onChannelUnfrozen(Rt)})),[2]}))}))})),[3,77];case 63:return[4,this.getChannel(pe.channelUrl,!0)];case 64:return Ot=Un.sent(),Ht=e.as(Qn),Gt=Ht.allowAutoUnhide,Vt=Ht.hidePreviousMessages,qt=Ht.messageOffsetTimestamp,null!==Gt&&(Ot.hiddenState=Gt?rs.HIDDEN_ALLOW_AUTO_UNHIDE:rs.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Vt&&Vt&&Ot._updateUnreadCount(0,0),null!==qt&&(Ot.messageOffsetTimestamp=qt),this._dispatcher.dispatch(new We({channels:[Ot],source:ze.EVENT_CHANNEL_HIDDEN})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelHidden&&e.onChannelHidden(Ot)})),[2]}))}))})),[3,77];case 65:return[4,this.getChannel(pe.channelUrl,!0)];case 66:return(Bt=Un.sent()).hiddenState=rs.UNHIDDEN,this._dispatcher.dispatch(new We({channels:[Bt],source:ze.EVENT_CHANNEL_UNHIDDEN})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Bt)})),[2]}))}))})),[3,77];case 67:return[4,this.getChannel(pe.channelUrl,!0)];case 68:return Wt=Un.sent(),this._dispatcher.dispatch(new Be({channelUrls:[pe.channelUrl],source:ze.EVENT_CHANNEL_DELETED})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Wt.url,Wt.channelType)})),[2]}))}))})),[3,77];case 69:return[4,this.getChannelWithoutCache(pe.channelUrl,!0)];case 70:return zt=Un.sent(),this._dispatcher.dispatch(new We({channels:[zt],source:ze.EVENT_CHANNEL_UPDATED})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(zt)})),[2]}))}))})),[3,77];case 71:return[4,this.getChannel(pe.channelUrl,!0)];case 72:return jt=Un.sent(),Qt=e.as(Ee),Kt=Qt.created,Yt=Qt.updated,Jt=Qt.deleted,Kt&&jt._upsertCachedMetaData(Kt,pe.ts),Yt&&jt._upsertCachedMetaData(Yt,pe.ts),Jt&&jt._removeFromCachedMetaData(Jt,pe.ts),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Kt&&e.onMetaDataCreated&&e.onMetaDataCreated(jt,Kt),Yt&&e.onMetaDataUpdated&&e.onMetaDataUpdated(jt,Yt),Jt&&e.onMetaDataDeleted&&e.onMetaDataDeleted(jt,Jt)})),[2]}))}))})),[3,77];case 73:return[4,this.getChannel(pe.channelUrl,!0)];case 74:return Xt=Un.sent(),Zt=e.as(Ce),$t=Zt.created,en=Zt.updated,tn=Zt.deleted,Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){$t&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Xt,$t),en&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Xt,en),tn&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Xt,tn)})),[2]}))}))})),[3,77];case 75:return[4,this.getChannel(pe.channelUrl,!0)];case 76:return nn=Un.sent(),rn=e.as(tr),sn=rn.pinnedMessageIds,an=rn.latestPinnedMessage,(on=rn.ts)>nn._pinnedMessagesUpdatedAt&&(nn.pinnedMessageIds=sn,nn.lastPinnedMessage=an,nn._pinnedMessagesUpdatedAt=on,this._dispatcher.dispatch(new We({channels:[nn],source:ze.EVENT_PINNED_MESSAGE_UPDATED})),Y((function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(nn)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(nn)})),[2]}))}))}))),[3,77];case 77:return[3,79];case 78:switch((un=e.as(Ze).event).category){case $e.USER_BLOCK:cn=et.getDataAsUserBlockEvent(this._iid,un),hn=cn.blocker,dn=cn.blockee,this._groupChannelCache.block(hn.userId,dn.userId);break;case $e.USER_UNBLOCK:ln=et.getDataAsUserBlockEvent(this._iid,un),hn=ln.blocker,dn=ln.blockee,this._groupChannelCache.unblock(hn.userId,dn.userId)}return[3,79];case 79:return[3,81];case 80:if(pn=Un.sent(),K(pn))throw pn;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===Ft.JOINED})).length},e.prototype.getChannel=function(e,t){return void 0===t&&(t=!1),g(this,void 0,void 0,(function(){var n;return y(this,(function(r){switch(r.label){case 0:f(b("string",e)).throw(_.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),g(this,void 0,void 0,(function(){var n,r,s,i,a;return y(this,(function(o){switch(o.label){case 0:return f(b("string",e)).throw(_.invalidParameters),n=new ln({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(n)];case 1:switch(r=o.sent(),s=r.as(hn).channel,i=s.unreadMessageCount,a=s.unreadMentionCount,s.myCountPreference){case ts.UNREAD_MESSAGE_COUNT_ONLY:a=0;break;case ts.UNREAD_MENTION_COUNT_ONLY:i=0;break;case ts.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=ze.REFRESH_CHANNEL),g(this,void 0,void 0,(function(){var r,s,i,a,o;return y(this,(function(u){switch(u.label){case 0:return u.trys.push([0,5,,6]),r=new ln({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(r)];case 1:return s=u.sent(),(i=s.as(hn).channel).myMemberState!==Ft.NONE?[3,2]:(this._dispatcher.dispatch(new Be({channelUrls:[i.url],source:n})),[3,4]);case 2:return[4,this.upsertChannelsToCache([i])];case 3:a=u.sent(),this._dispatcher.dispatch(new We({channels:a,source:n})),u.label=4;case 4:return[3,6];case 5:return(o=u.sent()).code!==X.NON_AUTHORIZED&&o.code!==X.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new Be({channelUrls:[e],source:n})),[3,6];case 6:return[2]}}))}))},e.prototype.getMyGroupChannels=function(e,t,n,r){return void 0===r&&(r=ze.REQUEST_CHANNEL),g(this,void 0,void 0,(function(){var s,a,o,u,c;return y(this,(function(l){switch(l.label){case 0:return s=new pn(i(i({},t),{userId:this._sdkState.userId,token:e,limit:n})),[4,this._requestQueue.send(s)];case 1:return a=l.sent(),o=a.as(fn),u=o.channels,c=o.token,this._dispatcher.dispatch(new We({channels:u,source:r})),[2,{channels:u,token:c}]}}))}))},e.prototype.getMessageFromCache=function(e){var t;return g(this,void 0,void 0,(function(){return y(this,(function(n){switch(n.label){case 0:return[4,this._messageCache.get(e)];case 1:return[2,null!==(t=n.sent())&&void 0!==t?t:null]}}))}))},e.prototype.getMessagesFromCache=function(e,t,n,r,s){return void 0===s&&(s=De),g(this,void 0,void 0,(function(){return y(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),g(this,void 0,void 0,(function(){return y(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 g(this,void 0,void 0,(function(){return y(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 g(this,void 0,void 0,(function(){return y(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 g(this,void 0,void 0,(function(){return y(this,(function(s){switch(s.label){case 0:return[4,this._messageCache.countBetween(e,t,new er({top:n,bottom:r}))];case 1:return[2,s.sent()]}}))}))},e.prototype.getMyGroupChannelChangeLogs=function(e,t,n){return void 0===n&&(n=ze.REQUEST_CHANNEL_CHANGELOGS),g(this,void 0,void 0,(function(){var r,a,o,u,c,l,h;return y(this,(function(d){switch(d.label){case 0:return r=i(i({},Zt),t),f((b("string",e)||b("number",e))&&$t(r)).throw(_.invalidParameters),a=new un(s({userId:this._sdkState.userId,ts:"number"==typeof e?e:null,token:"string"==typeof e?e:null,filter:r})),[4,this._requestQueue.send(a)];case 1:return o=d.sent(),u=o.as(cn),c=u.updatedChannels,l=u.deletedChannelUrls,h=u.hasMore,c.length>0&&this._dispatcher.dispatch(new We({channels:c,source:n})),l.length>0&&this._dispatcher.dispatch(new Be({channelUrls:l,source:n})),[2,{updatedChannels:c,deletedChannelUrls:l,hasMore:h,token:u.token}]}}))}))},e.prototype.getGroupChannelCount=function(e){return g(this,void 0,void 0,(function(){var t,n,r;return y(this,(function(s){switch(s.label){case 0:return t=i(i({},en),e),f(tn(t)).throw(_.invalidParameters),n=new _n({userId:this._sdkState.userId,filter:t}),[4,this._requestQueue.send(n)];case 1:return r=s.sent(),[2,r.as(mn).groupChannelCount]}}))}))},e.prototype.getUnreadItemCount=function(e){return g(this,void 0,void 0,(function(){var t,n,s,a,o,u,c,l,h,d,p,m,v,g,C,b;return y(this,(function(y){switch(y.label){case 0:return t=i(i({},nn),e),f(function(e){return E(Qt,e.keys)}(t)).throw(_.invalidParameters),n=j.of(this._iid),s=n.sdkState,a=n.requestQueue,o=new vn({userId:s.userId,filter:t}),[4,a.send(o)];case 1:return u=y.sent(),c=u.as(gn),l=c.groupChannelUnreadMentionCount,h=c.groupChannelUnreadMessageCount,d=c.groupChannelInvitationCount,p=c.superGroupChannelUnreadMentionCount,m=c.superGroupChannelUnreadMessageCount,v=c.superGroupChannelInvitationCount,g=c.nonSuperGroupChannelUnreadMentionCount,C=c.nonSuperGroupChannelUnreadMessageCount,b=c.nonSuperGroupChannelInvitationCount,[2,r({groupChannelUnreadMentionCount:l,groupChannelUnreadMessageCount:h,groupChannelInvitationCount:d,superGroupChannelUnreadMentionCount:p,superGroupChannelUnreadMessageCount:m,superGroupChannelInvitationCount:v,nonSuperGroupChannelUnreadMentionCount:g,nonSuperGroupChannelUnreadMessageCount:C,nonSuperGroupChannelInvitationCount:b})]}}))}))},e.prototype.getTotalUnreadChannelCount=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){switch(i.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new yn({userId:t.userId}),[4,n.send(r)];case 1:return s=i.sent(),[2,s.as(Cn).unreadCount]}}))}))},e.prototype.getTotalUnreadMessageCount=function(e){return g(this,void 0,void 0,(function(){var t,n,r,s,o,u;return y(this,(function(c){switch(c.label){case 0:return t=i(i({},rn),e),f(function(e){return E("string",e.channelCustomTypesFilter,!0)&&a(Ht,e.superChannelFilter)}(t)).throw(_.invalidParameters),n=j.of(this._iid),r=n.sdkState,s=n.requestQueue,o=new En({userId:r.userId,filter:t}),[4,s.send(o)];case 1:return u=c.sent(),[2,u.as(bn).unreadCount]}}))}))},e.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),g(this,void 0,void 0,(function(){var t,n,r,s;return y(this,(function(o){switch(o.label){case 0:return t=i(i({},sn),e),f(function(e){return b("string",e.channelUrl,!0)&&E(yt,e.scheduledStatus,!0)&&a(N,e.messageTypeFilter)}(t)).throw(_.invalidParameters),n=j.of(this._iid).requestQueue,r=new Mn(t),[4,n.send(r)];case 1:return s=o.sent(),[2,s.as(Nn).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 g(this,void 0,void 0,(function(){var t,n,r,s;return y(this,(function(a){switch(a.label){case 0:return t=i(i({},Jt),e),f(Xt(t)).throw(_.invalidParameters),t.isPublic||(t.accessCode=void 0),n=new Sn(i({userId:this._sdkState.userId},t)),[4,this._requestQueue.send(n)];case 1:return r=a.sent(),s=r.as(Tn).channel,[4,this.upsertChannelsToCache([s])];case 2:return a.sent(),[2,s]}}))}))},e.prototype.markAsReadAll=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,o;return y(this,(function(u){switch(u.label){case 0:return e=Date.now(),f(e-this._markAsReadAllLastSentAt>=1e3).throw(_.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=e,t=new An({userId:this._sdkState.userId}),[4,this._requestQueue.send(t)];case 1:u.sent(),n=this._groupChannelCache.channels;try{for(r=C(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 g(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,c;return y(this,(function(l){switch(l.label){case 0:return t=Date.now(),f(E("string",e)&&t-this._markAsReadAllLastSentAt>=1e3).throw(_.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new An({userId:this._sdkState.userId,channelUrls:e}),[4,this._requestQueue.send(n)];case 1:l.sent(),r=this._groupChannelCache.channels,s=[];try{for(i=C(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 g(this,void 0,void 0,(function(){return y(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"}(qn||(qn={}));var sr,ir=function(t){function n(e,n,r,s){var i=t.call(this)||this;return i._state=qn.IDLE,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===qn.IDLE},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRunning",{get:function(){return this._state===qn.RUNNING},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isDone",{get:function(){return this._state===qn.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 g(this,void 0,void 0,(function(){var t,n;return y(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})),(null===(l=this._metadata)||void 0===l?void 0:(i=l.range).intersect.apply(i,m([],v(r),!1)))?this.extendRange(n):this._metadata={range:new er({top:Math.min.apply(Math,m([],v(r),!1)),bottom:Math.max.apply(Math,m([],v(r),!1))}),previousComplete:!1}),t.hasNext=n.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(t.nextToken=this._metadata.range.top,this._metadata.previousComplete=n.length0&&(r=n.map((function(e){return e.createdAt})),(null===(c=this._metadata)||void 0===c?void 0:(i=c.range).intersect.apply(i,m([],v(r),!1)))?this.extendRange(n):this._metadata={range:new er({top:Math.min.apply(Math,m([],v(r),!1)),bottom:Math.max.apply(Math,m([],v(r),!1))}),previousComplete:!1}),t.hasNext=n.length>=this._limit&&this._nextSyncLoopCount<1,this._metadata&&(t.nextToken=this._metadata.range.bottom),h.debug("message background next sync progress",t),[4,this.saveMetadata()];case 4:return l.sent(),[3,6];case 5:throw s=l.sent(),h.debug("message background next sync error",s),s;case 6:return[2,t]}}))}))})),this._connectionEventContext=l.on((function(e){if(e instanceof ee)if(e.stateType===te.CONNECTED)i.resume();else i.pause()}))}return e.of=function(t,n){return ur[t]||(ur[t]={}),ur[t][n.url]||(ur[t][n.url]=new e({_iid:t,channel:n})),ur[t][n.url].ref++,ur[t][n.url]},e.clear=function(e,t){ur[e]&&ur[e][t]&&(ur[e][t].close(),delete ur[e])},Object.defineProperty(e.prototype,"range",{get:function(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new er({})},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,m([],v(e.map((function(e){return e.createdAt}))),!1))},e.prototype.extendRange=function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,m([],v(e.map((function(e){return e.createdAt}))),!1))},e.prototype.loadMetadata=function(e){return g(this,void 0,void 0,(function(){var t;return y(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&&(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 _&&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 ee)if(e.stateType===te.CONNECTED)r.resume();else r.pause()}))}return e.of=function(t,n){return lr[t]||(lr[t]={}),lr[t][n.url]||(lr[t][n.url]=new e({_iid:t,channel:n})),lr[t][n.url].ref++,lr[t][n.url]},e.clear=function(e,t){lr[e]&&lr[e][t]&&(lr[e][t].close(),delete lr[e])},e.prototype.loadMetadata=function(){return g(this,void 0,void 0,(function(){var e,t,n,r;return y(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 g(this,void 0,void 0,(function(){return y(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 g(this,void 0,void 0,(function(){return y(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=void 0,[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 lr[this._iid][this._channel.url])},e}(),dr={},pr=function(){function e(e){var t=e._iid,n=e.channel,r=e.hasPollMessage,s=this;this.ref=0,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 ir(h,(function(){return g(s,void 0,void 0,(function(){var e,t,n,s,i,a,o,c;return y(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,Rt.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 _&&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 ee)if(e.stateType===te.CONNECTED)s.resume();else s.pause()}))}return e.of=function(t,n,r){return dr[t]||(dr[t]={}),dr[t][n.url]||(dr[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r})),dr[t][n.url].ref++,dr[t][n.url]},e.prototype.loadMetadata=function(){return g(this,void 0,void 0,(function(){var e;return y(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}:void 0,t.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return g(this,void 0,void 0,(function(){return y(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 g(this,void 0,void 0,(function(){return y(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=void 0,[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 dr[this._iid][this._channel.url])},e}(),fr=function(t){function n(e){var n,s,i,a,o,u,c=this;return(c=t.call(this)||this).method=D.GET,c.path="".concat(re(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}(R),_r=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 bt(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 bt(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}(F),mr=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},vr=function(e,t,n){if(e.length>0){for(var r=mr(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:gr(e[a],t,n)>=0?a:a+1,oldPosition:r}}return{place:e.length,oldPosition:-1}},gr=function(e,t,n){switch(n){case Ge.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 Ge.CHRONOLOGICAL:return t.createdAt-e.createdAt;case Ge.CHANNEL_NAME_ALPHABETICAL:var r=e.name.localeCompare(t.name);return 0===r?e.createdAt-t.createdAt:r;default:return 0}},yr=function(e,t){return t instanceof Ct?e.findIndex((function(e){return e instanceof Ct&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},Cr=function(e,t){return e.findIndex((function(e){return e.messageId===t}))},Er=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,s=Math.floor((n+r)/2);n0)r=s,s=Math.floor((n+r)/2);else{if(!(i<0))return s;n=s+1,s=Math.floor((n+r)/2)}}return e[s].createdAt>t.createdAt?s:s+1}return e.length},br=6e5;!function(e){e.CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api"}(sr||(sr={}));var Mr,Nr,Ur,Sr=function(){function e(){}return e.prototype._invokeResponse=function(e,t,n){var r=this;Y((function(){return g(r,void 0,void 0,(function(){return y(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}(),Tr=function(){function e(e,t){var n=t.channel,r=t.filter,s=t.startingPoint,i=t.limit,a=this;this._messages=[],this._unsentMessages=[],this._iid=e,this._key="mc-".concat(oe()),this.filter=null!=r?r:new Je,this._channel=n,this._syncRange=new er({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof s?s:Date.now()+br,this._limit=i||De;var o=rr.of(this._iid);o.subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t,n){var r=mr(e,a._channel);if(r>=0){switch(a._channel=e[r],t){case ze.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})),J.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!s&&a._messages.length>0&&a._removeMessagesFromView(a._messages.map((function(e){return e.messageId})),J.EVENT_MESSAGE_OFFSET_UPDATED);break;case ze.EVENT_CHANNEL_UNMUTED:var c=n;j.of(a._iid).sdkState.userId===c&&a._clearCheckMyMutedTimer();break;case ze.EVENT_CHANNEL_MUTED:var l=n;j.of(a._iid).sdkState.userId===l&&-1!==a.channel._myMutedRemainingTime&&a._startCheckMyMutedTimer(a.channel._myMutedRemainingTime);break;case ze.EVENT_CHANNEL_LEFT:a.channel.isPublic&&a._clearCheckMyMutedTimer()}Y((function(){return g(a,void 0,void 0,(function(){var e,n;return y(this,(function(r){return e=new ar(t),tt(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(),Y((function(){return g(a,void 0,void 0,(function(){var e,n;return y(this,(function(r){return e=new ar(t),(null===(n=this._handler)||void 0===n?void 0:n.onChannelDeleted)&&this._handler.onChannelDeleted(e,this.channel.url),[2]}))}))})))}}),o.subscribeMessageEvent(this._key,{onUpdate:function(e,t){var n,r,s=[],i=[];try{for(var o=C(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(se(t)){if(s.length>0)switch(t){case J.EVENT_MESSAGE_SENT_FAILED:case J.EVENT_MESSAGE_SENT_SUCCESS:case J.EVENT_MESSAGE_UPDATED:case J.EVENT_MESSAGE_THREADINFO_UPDATED:case J.EVENT_MESSAGE_REACTION_UPDATED:case J.SYNC_MESSAGE_CHANGELOGS:a._updateMessagesToView(s,t);break;case J.EVENT_MESSAGE_SENT_PENDING:a._addMessagesToView(s,t);break;case J.EVENT_MESSAGE_RECEIVED:a.hasNext||a._addMessagesToView(s,t);break;case J.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 We({channels:[this._channel],source:ze.CHANNEL_LASTACCESSEDAT_UPDATED})),!this._channel.isSuper&&c.localCacheEnabled&&(this._backgroundSync=cr.of(this._iid,this._channel),this._backgroundSync.resume(this._startingPoint)),this._changelogSync=hr.of(this._iid,this._channel),this._changelogSync.resume(),this._pollChangelogSync=pr.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new ir(this._key,(function(e){return g(a,void 0,void 0,(function(){var t,n,r,s,i;return y(this,(function(a){switch(a.label){case 0:return[4,this._getRemoteMessages(e,{prevLimit:this._limit,source:J.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,m([],v(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,m([],v(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 ee)switch(e.stateType){case te.CONNECTED:a._refreshChannel(ze.SYNC_CHANNEL_CHANGELOGS),U((function(){return g(a,void 0,void 0,(function(){var e;return y(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 te.LOGOUT:a.dispose();break;default:a._clearCheckMyMutedTimer(),a._prevFill.stop(),a._nextFill.stop()}})),j.of(this._iid).statLogCollector.put(new ie({type:ae.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 m([],v(this._messages),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"failedMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===ue.FAILED}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pendingMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===ue.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,m(m([],v(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,m(m([],v(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=C(i),c=u.next();!c.done;c=u.next()){var l=c.value;if(t===J.SYNC_MESSAGE_FILL){if(l.messageId>0){if((f=yr(this._messages,l))<0){yr(this._unsentMessages,l)<0&&a.push(l);var h=Er(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof Ct){(f=yr(this._unsentMessages,l))<0&&yr(this._messages,l)<0&&(this._unsentMessages.push(l),a.push(l))}}else if(l.messageId>0){if((f=yr(this._messages,l))<0){var d=yr(this._unsentMessages,l);d<0?a.push(l):(this._unsentMessages.splice(d,1),o.push(l));h=Er(this._messages,l);this._messages.splice(h,0,l)}else o.push(l),this._messages[f]=l;if(l.updatedAt>0){var p=this._updateChildMessagesInView(l);o.push.apply(o,m([],v(p),!1))}}else if(l instanceof Ct){var f;(f=yr(this._unsentMessages,l))<0?yr(this._messages,l)<0&&(this._unsentMessages.push(l),a.push(l)):(o.push(l),this._unsentMessages[f]=l)}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}se(t)&&Y((function(){return g(s,void 0,void 0,(function(){var e,n,r;return y(this,(function(s){return e=new or(t),a.length>0&&(null===(n=this._handler)||void 0===n||n.onMessagesAdded(e,this.channel,a)),o.length>0&&(null===(r=this._handler)||void 0===r||r.onMessagesUpdated(e,this.channel,o)),[2]}))}))}))},e.prototype._updateChildMessagesInView=function(e){var t=[];return this._messages.forEach((function(n){n.applyParentMessage(e)&&t.push(n)})),t},e.prototype._updatePollsToView=function(e,t){var n,r,s=this,i=[];try{for(var a=C(e),o=a.next();!o.done;o=a.next()){var u=o.value,c=Cr(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&&se(t)&&Y((function(){return g(s,void 0,void 0,(function(){var e,n;return y(this,(function(r){return e=new or(t),i.length>0&&(null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,i)),[2]}))}))})),i},e.prototype._applyPollUpdateEventToView=function(e,t){var n=this,r=Cr(this._messages,e.messageId);if(r>=0){var s=this._messages[r];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollUpdateEvent(e)&&se(t)&&Y((function(){return g(n,void 0,void 0,(function(){var e,n;return y(this,(function(r){return e=new or(t),null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,[s]),[2]}))}))}))}},e.prototype._applyPollVoteEventToView=function(e,t){var n=this,r=Cr(this._messages,e.messageId);if(r>=0){var s=this._messages[r];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollVoteEvent(e)&&se(t)&&Y((function(){return g(n,void 0,void 0,(function(){var e,n;return y(this,(function(r){return e=new or(t),null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,[s]),[2]}))}))}))}},e.prototype._updateMessagesToView=function(e,t){var n,r,s=this,i=[],a=[];try{for(var o=C(e),u=o.next();!u.done;u=o.next()){var c,l=u.value;if(l.messageId>0)if((c=yr(this._messages,l))>=0)i.push(l),this._messages[c]=l;else{var h=yr(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=Er(this._messages,l);this._messages.splice(p,0,l)}}}else if(l instanceof Ct)(c=yr(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 se(t)&&Y((function(){return g(s,void 0,void 0,(function(){var e,n,r;return y(this,(function(s){return e=new or(t),i.length>0?null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,i):a.length>0&&(null===(r=this._handler)||void 0===r||r.onMessagesDeleted(e,this.channel,[],a)),[2]}))}))})),i},e.prototype._removeMessagesFromView=function(e,t){var n,r,s=this,i=[],a=[],o=function(e){var t=u._messages.findIndex((function(t){return t.messageId===e}));if(t>=0){var n=u._messages[t];i.push(n.messageId),a.push(n),u._messages.splice(t,1)}},u=this;try{for(var c=C(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 se(t)&&a.length>0&&Y((function(){return g(s,void 0,void 0,(function(){var e,n;return y(this,(function(r){return e=new or(t),null===(n=this._handler)||void 0===n||n.onMessagesDeleted(e,this.channel,i,a),[2]}))}))})),i},e.prototype._removeUnsentMessageFromView=function(e,t){var n=this._unsentMessages.findIndex((function(t){return t.reqId===e}));n>=0&&this._unsentMessages.splice(n,1)},e.prototype._getLocalMessages=function(e,t){var n=t.prevLimit,r=void 0===n?0:n,s=t.nextLimit,i=void 0===s?0:s;return g(this,void 0,void 0,(function(){var t,n,s,a,o,u,c;return y(this,(function(l){switch(l.label){case 0:return t=rr.of(this._iid),r>0?[4,t.getMessagesFromCache(this._channel.url,e,"prev",this.filter,r)]:[3,2];case 1:return s=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,m(m([],v(n),!1),v(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,a=t.nextLimit,o=void 0===a?0:a,u=t.source,c=void 0===u?J.REQUEST_MESSAGE:u,l=t.reverse,h=void 0!==l&&l,d=t.checkingContinuousMessages,p=void 0!==d&&d;return g(this,void 0,void 0,(function(){var t,n;return y(this,(function(a){switch(a.label){case 0:return t=St.of(this._iid),r>0||o>0?[4,t._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,e,s(i(i({},this.filter),{isInclusive:!0,reverse:h,prevResultSize:r,nextResultSize:o,includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0})),c,p)]:[3,2];case 1:return n=a.sent(),[3,3];case 2:n={messages:[],isContinuousMessages:!1},a.label=3;case 3:return[2,n]}}))}))},e.prototype._checkHugeGap=function(){var e;return g(this,void 0,void 0,(function(){var t,n,r,s,a,o,u,c,l,h,d,p,f,C,E,b,M,N,U,S,T=this;return y(this,(function(A){switch(A.label){case 0:return this._messages.length>0?(t=this._syncRange.top,n=this.viewTop,r=this._syncRange.bottom,s=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,[4,(a=rr.of(this._iid)).getCachedMessageCountBetween(this._channel.url,this.filter,n,t)]):[3,4];case 1:return o=A.sent(),[4,a.getCachedMessageCountBetween(this._channel.url,this.filter,r,s)];case 2:return u=A.sent(),[4,ce((function(){return g(T,void 0,void 0,(function(){var e,a,c,l,h,d,p,f,_,C,E,b,M,N,U,S,T,A,I,w,D,k=this;return y(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 fr(i({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:n,prevEnd:t,prevCount:o,nextStart:r,nextEnd:s,nextCount:u,checkingContinuousMessages:l.localCacheEnabled},this.filter)),[4,c.send(h)];case 1:return d=P.sent(),p=d.as(_r),f=p.isHugeGap,_=p.prevMessages,C=void 0===_?[]:_,E=p.prevHasMore,b=p.isContinuousPrevMessages,M=p.nextMessages,N=void 0===M?[]:M,U=p.nextHasmore,S=p.isContinuousNextMessages,f?Y((function(){return g(k,void 0,void 0,(function(){var e;return y(this,(function(t){return null===(e=this._handler)||void 0===e||e.onHugeGapDetected(),[2]}))}))})):(this._hasPrevious=E,this._hasNext=U,T=this.viewTop,A=this.viewBottom,I=Math.min.apply(Math,m([Number.MAX_SAFE_INTEGER,T],v(C.map((function(e){return e.createdAt}))),!1)),w=Math.max.apply(Math,m([0,A],v(N.map((function(e){return e.createdAt}))),!1)),a.dispatch(new L({messages:C,source:J.SYNC_MESSAGE_FILL})),a.dispatch(new L({messages:N,source:J.SYNC_MESSAGE_FILL})),this._syncRange.extends(I,w),(b||S)&&(null===(D=this._backgroundSync)||void 0===D||D.range.extends(I,w)),Tw&&this._nextFill.start(w)),[2]}}))}))}),1)];case 3:return A.sent(),[3,8];case 4:c=j.of(this._iid).cacheContext,l=Math.floor(this._limit/2),h=Date.now(),A.label=5;case 5:return A.trys.push([5,7,,8]),[4,this._getRemoteMessages(h,{prevLimit:l,nextLimit:l,source:J.SYNC_MESSAGE_FILL,checkingContinuousMessages:c.localCacheEnabled})];case 6:if(d=A.sent(),p=d.messages,f=d.isContinuousMessages,p.length>0){for(C=p.map((function(e){return e.createdAt})),E=0,b=0,M=0;M=h&&b++;this._hasPrevious=E>=l,this._hasNext=b>=l,(S=this._syncRange).extends.apply(S,m([],v(C),!1)),f&&(null===(e=this._backgroundSync)||void 0===e||e.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(p,J.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;return[3,8];case 7:return(U=A.sent())instanceof _&&U.code===X.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1),[3,8];case 8:return[2]}}))}))},e.prototype._loadUnsentMessages=function(){return g(this,void 0,void 0,(function(){var e,t;return y(this,(function(n){switch(n.label){case 0:return e=rr.of(this._iid),t=this,[4,e.getUnsentMessagesFromCache(this._channel.url,this.filter)];case 1:return t._unsentMessages=n.sent(),[2]}}))}))},e.prototype._hasPollMessage=function(){return g(this,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,rr.of(this._iid).getPollMessagesFromCache(this._channel.url,Date.now()+br,this.filter,1)];case 1:return e.sent().length>0?[2,!0]:[2,!1]}}))}))},e.prototype._refreshChannel=function(e){rr.of(this._iid).refreshChannel(this.channel.url,!0,e)},e.prototype._startCheckMyMutedTimer=function(e){var t=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return g(t,void 0,void 0,(function(){var e,t,n,r;return y(this,(function(s){switch(s.label){case 0:this._checkMyMutedStateTimer=void 0,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=ns.UNMUTED,n=new ar(ze.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=void 0)},e.prototype.initialize=function(e){var t=this,n=new Sr;this._messages=[],this._unsentMessages=[],this._syncRange=new er({}),this._hasNext=!0,this._hasPrevious=!0,this._refreshChannel(ze.REFRESH_CHANNEL),U((function(){return g(t,void 0,void 0,(function(){var e;return y(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===sr.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:r,nextLimit:r}).then((function(e){return g(t,void 0,void 0,(function(){var t;return y(this,(function(r){switch(r.label){case 0:return t=this._filterUnderOffsetMessage(e),this._addMessagesToView(t,J.REQUEST_MESSAGE),[4,this._loadUnsentMessages()];case 1:return r.sent(),n._invokeResponse("local",null,t),[2]}}))}))})).catch((function(e){if(K(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,d=0;d=t._startingPoint&&h++}t._hasPrevious=l>=r,t._hasNext=h>=r,(s=t._syncRange).extends.apply(s,m([],v(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,J.REQUEST_MESSAGE)}else t._hasPrevious=!1,t._hasNext=!1;n._invokeResponse("remote",null,u)})).catch((function(e){if(K(e))throw e;n._invokeResponse("remote",e,null)}))}));var s=j.of(this._iid),i=s.cacheContext;return s.statLogCollector.put(new ie({type:ae.FEATURE_LOCALCACHE,data:{use_local_cache:i.localCacheEnabled,collection_interface:{message_init_policy:e}}})),n},e.prototype.loadPrevious=function(){return g(this,void 0,void 0,(function(){var e,t,n,r=this;return y(this,(function(s){switch(s.label){case 0:return this._hasPrevious?(e=this.viewTop,t=[],[4,U((function(){return g(r,void 0,void 0,(function(){var n;return y(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,U((function(){return g(r,void 0,void 0,(function(){var n,r,s,i,a;return y(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,m([],v(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,J.REQUEST_MESSAGE),[3,4];case 3:this._hasPrevious=t.length>=this._limit,t.length>0&&((n=this._syncRange).extends.apply(n,m([],v(t.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(t,J.REQUEST_MESSAGE)),s.label=4;case 4:return[2,t];case 5:return[2,[]]}}))}))},e.prototype.loadNext=function(){var e;return g(this,void 0,void 0,(function(){var t,n,r,s=this;return y(this,(function(i){switch(i.label){case 0:return this._hasNext?(t=this.viewBottom,n=[],[4,U((function(){return g(s,void 0,void 0,(function(){var e;return y(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,U((function(){return g(s,void 0,void 0,(function(){var e,r,s,i,a;return y(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,m([],v(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,J.REQUEST_MESSAGE),[3,4];case 3:this._hasNext=n.length>=this._limit,n.length>0&&((r=this._syncRange).extends.apply(r,m([],v(n.map((function(e){return e.createdAt}))),!1)),this._addMessagesToView(n,J.REQUEST_MESSAGE)),i.label=4;case 4:return[2,n]}}))}))},e.prototype.removeFailedMessage=function(e){return g(this,void 0,void 0,(function(){var t;return y(this,(function(n){switch(n.label){case 0:return[4,rr.of(this._iid).removeFailedMessageFromCache(e)];case 1:return n.sent(),(t=this._unsentMessages.findIndex((function(t){return t.reqId===e})))>-1&&this._unsentMessages.splice(t,1),[2]}}))}))},e.prototype.dispose=function(){var e,t,n,r=j.of(this._iid),s=r.cacheContext,i=r.dispatcher;this._clearCheckMyMutedTimer(),this._channel._updateMessageCollectionLastAccessedAt(),i.dispatch(new We({channels:[this._channel],source:ze.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=rr.of(this._iid);a.unsubscribeGroupChannelEvent(this._key),a.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()},e}(),Ar={coverUrl:void 0,coverImage:void 0,isDistinct:void 0,isPublic:void 0,isDiscoverable:void 0,accessCode:void 0,name:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,messageSurvivalSeconds:void 0},Ir=function(t){function n(e){var n=this,r=e.channelUrl,s=e.token,i=e.limit,a=e.order,o=e.mutedMemberFilter,u=e.memberStateFilter,c=e.nicknameStartsWithFilter,l=e.operatorFilter;return(n=t.call(this)||this).method=D.GET,n.path="".concat(O,"/").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}(R),wr=function(t){function n(e,n){var r=t.call(this,e,n)||this;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 zt(e,t)}))),r}return e(n,t),n}(F);!function(e){e.ALL="all",e.MUTED="muted",e.UNMUTED="unmuted"}(Mr||(Mr={})),function(e){e.MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",e.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical"}(Nr||(Nr={})),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"}(Ur||(Ur={}));var Lr=function(t){function n(e,n,r){var s,i,a,o,c=this;return(c=t.call(this,e,n,u.GROUP,r)||this).mutedMemberFilter=Mr.ALL,c.memberStateFilter=Ur.ALL,c.nicknameStartsWithFilter=null,c.operatorFilter=qt.ALL,c.order=Nr.MEMBER_NICKNAME_ALPHABETICAL,c.mutedMemberFilter=null!==(s=r.mutedMemberFilter)&&void 0!==s?s:Mr.ALL,c.memberStateFilter=null!==(i=r.memberStateFilter)&&void 0!==i?i:Ur.ALL,c.nicknameStartsWithFilter=null!==(a=r.nicknameStartsWithFilter)&&void 0!==a?a:null,c.order=null!==(o=r.order)&&void 0!==o?o:Nr.MEMBER_NICKNAME_ALPHABETICAL,c}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&a(Mr,this.mutedMemberFilter)&&a(Ur,this.memberStateFilter)&&(b("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&a(qt,this.operatorFilter)&&a(Nr,this.order)},n.prototype.next=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,a,o;return y(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 Ir(s(i(i({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=u.sent(),r=n.as(wr),a=r.members,o=r.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},n}(le),Dr=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.accessCode;return(n=t.call(this)||this).method=D.PUT,n.path="".concat(O,"/").concat(encodeURIComponent(r),"/accept"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(R),kr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new cs(e,n),r.channel.myMemberState=Ft.JOINED,r}return e(n,t),n}(F),Pr=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=D.PUT,n.path="".concat(O,"/").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}(R),Rr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new cs(e,n),r}return e(n,t),n}(F),Fr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=D.DELETE,n.path="".concat(O,"/").concat(encodeURIComponent(r)),n}return e(n,t),n}(R);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(F);var xr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=D.DELETE,n.path="".concat(O,"/").concat(encodeURIComponent(r),"/hide"),n}return e(n,t),n}(R);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(F);var Or=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=e.countPreference,i=t.call(this)||this;return i.method=D.PUT,i.path="".concat(k,"/").concat(encodeURIComponent(n),"/count_preference/").concat(encodeURIComponent(r)),i.params={count_preference:s},i}return e(n,t),n}(R),Hr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.countPreference=n.count_preference,r}return e(n,t),n}(F),Gr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=D.PUT,n.path="".concat(O,"/").concat(encodeURIComponent(r),"/reset_user_history"),n}return e(n,t),n}(R),Vr=function(t){function n(e,n){var r=t.call(this,e,n)||this,s=n.ts_message_offset;return r.messageOffsetTimestamp=s,r}return e(n,t),n}(F),qr=i(i({},ke),{scheduledAt:void 0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Br=i(i({},Re),{scheduledAt:void 0}),Wr=function(t){function n(e){var n,i=this;i=t.call(this)||this;var a=[];e.mentionType===he.USERS&&(e.mentionedUserIds?a=e.mentionedUserIds:e.mentionedUsers&&(a=e.mentionedUsers.map((function(e){return e.userId}))));var o=e.channelType,u=e.channelUrl,c=e.scheduledMessageId;return i.method=D.PUT,i.path="".concat(re(o),"/").concat(encodeURIComponent(u),"/scheduled_messages/").concat(encodeURIComponent(c)),i.params=r(s({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:de.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 Tt.payloadify(e)})):[],custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:a,sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return At.payloadify(e)})),apple_critical_alert_options:e.appleCriticalAlertOptions?It.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption})),i}return e(n,t),n}(R),zr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new Nt(e,n),r}return e(n,t),n}(F),jr=function(t){function n(e){var n,i=this;i=t.call(this)||this;var a=[];e.mentionType===he.USERS&&(e.mentionedUserIds?a=e.mentionedUserIds:e.mentionedUsers&&(a=e.mentionedUsers.map((function(e){return e.userId}))));var o=e.channelType,u=e.channelUrl,c=e.scheduledMessageId;return i.method=D.PUT,i.path="".concat(re(o),"/").concat(encodeURIComponent(u),"/scheduled_messages/").concat(encodeURIComponent(c)),i.params=r(s({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:de.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:a,sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return At.payloadify(e)})),apple_critical_alert_options:e.appleCriticalAlertOptions?It.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption})),i}return e(n,t),n}(R);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new Mt(e,n),r}e(n,t)}(F);var Qr=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,i=e.scheduledMessageId;return n.method=D.DELETE,n.path="".concat(re(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i)),n}return e(n,t),n}(R),Kr=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,i=e.scheduledMessageId;return n.method=D.POST,n.path="".concat(re(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i),"/send_now"),n}return e(n,t),n}(R),Yr=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=e.pushTriggerOption,i=t.call(this)||this;return i.method=D.PUT,i.path="".concat(k,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(r)),i.params={push_trigger_option:s},i}return e(n,t),n}(R),Jr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r.enabled=n.enable,r}return e(n,t),n}(F),Xr=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=t.call(this)||this;return s.method=D.GET,s.path="".concat(k,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(r)),s}return e(n,t),n}(R),Zr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r.enabled=n.enable,r}return e(n,t),n}(F),$r=function(t){function n(e){var n=e.channelType,r=e.channelUrl,s=e.messageId,i=t.call(this)||this;return i.method=D.POST,i.path="".concat(re(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),i}return e(n,t),n}(R);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(F);var es=function(t){function n(e){var n=e.channelType,r=e.channelUrl,s=e.messageId,i=t.call(this)||this;return i.method=D.DELETE,i.path="".concat(re(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),i}return e(n,t),n}(R);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(F);var ts,ns,rs,ss=function(t){function n(e,n){var r=t.call(this,e)||this;return r.message=bt(e,n.message),r}return e(n,t),n}(h),is=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=D.GET,n.path="".concat(re(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}(R),as=function(t){function n(e,n){var r=t.call(this,e,n)||this,s=n.pinned_messages,i=n.has_more,a=n.next;return r.pinnedMessages=s.map((function(t){return new ss(e,t)})),r.hasMore=i,r.token=a,r}return e(n,t),n}(F),os=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)&&b("boolean",this.includeMetaArray,!0)&&b("boolean",this.includeReactions,!0)&&b("boolean",this.includeParentMessageInfo,!0)&&b("boolean",this.includeThreadInfo,!0)&&b("boolean",this.includePollDetails,!0)},n.prototype.next=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,s,a,o;return y(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 is(i(i({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=u.sent(),r=n.as(as),s=r.pinnedMessages,a=r.hasMore,o=r.token,this._token=o,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},n}(le);!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"}(ts||(ts={})),function(e){e.MUTED="muted",e.UNMUTED="unmuted"}(ns||(ns={})),function(e){e.UNHIDDEN="unhidden",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(rs||(rs={}));var us,cs=function(t){function n(e,n){var r,s,l,h,d,p,f,_,g,y,C,E,M,N,U,S,T,A,I,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=rs.UNHIDDEN,w.lastMessage=null,w.messageOffsetTimestamp=0,w.messageSurvivalSeconds=-1,w.myMemberState=Ft.NONE,w.myRole=o.NONE,w.myMutedState=ns.UNMUTED,w.myLastRead=0,w.myCountPreference=ts.ALL,w.myPushTriggerOption=fe.DEFAULT,w.inviter=null,w.invitedAt=0,w.joinedAt=0,w.pinnedMessageIds=[],w.lastPinnedMessage=null,w._pinnedMessagesUpdatedAt=0,w._myMutedRemainingTime=-1,w.channelType=u.GROUP,w.isDistinct=null!==(s=n.is_distinct)&&void 0!==s&&s,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!==(d=n.is_exclusive)&&void 0!==d&&d,w.isPublic=null!==(p=n.is_public)&&void 0!==p&&p,w.isDiscoverable=null!==(f=n.is_discoverable)&&void 0!==f?f:w.isPublic,w.isAccessCodeRequired=null!==(_=n.is_access_code_required)&&void 0!==_&&_,w.isPushEnabled=null!==(g=n.is_push_enabled)&&void 0!==g&&g,Array.isArray(n.members)&&(r=w.members).push.apply(r,m([],v(n.members.map((function(e){return new zt(w._iid,e)}))),!1)),w.memberCount=null!==(y=n.member_count)&&void 0!==y?y:0,w.joinedMemberCount=null!==(C=n.joined_member_count)&&void 0!==C?C:0,w.hiddenState=a(rs,n.hidden_state)?n.hidden_state:rs.UNHIDDEN,w.messageOffsetTimestamp=null!==(E=n.ts_message_offset)&&void 0!==E?E:0,w.messageSurvivalSeconds=null!==(M=n.message_survival_seconds)&&void 0!==M?M:-1,w.lastMessage=n.last_message?bt(w._iid,i({channel_type:w.channelType},n.last_message)):null,n.read_receipt&&Object.keys(n.read_receipt).forEach((function(e){b("number",n.read_receipt[e])&&w._updateUnreadMemberState(e,n.read_receipt[e])})),n.delivery_receipt&&Object.keys(n.delivery_receipt).forEach((function(e){b("number",n.delivery_receipt[e])&&w._updateUndeliveredMemberState(e,n.delivery_receipt[e])})),w.myMemberState=a(Ft,n.member_state)?n.member_state:Ft.NONE,w.myRole=a(o,n.my_role)?n.my_role:o.NONE,a(ns,n.is_muted)?w.myMutedState=n.is_muted:b("boolean",n.is_muted)?w.myMutedState=n.is_muted?ns.MUTED:ns.UNMUTED:w.myMutedState=ns.UNMUTED,w.myCountPreference=a(ts,n.count_preference)?n.count_preference:ts.ALL,w.myPushTriggerOption=a(fe,n.push_trigger_option)?n.push_trigger_option:fe.ALL,w.myLastRead=null!==(N=n.user_last_read)&&void 0!==N?N:0,w.inviter=n.inviter?new c(w._iid,n.inviter):null,w.invitedAt=null!==(U=n.invited_at)&&void 0!==U?U:0,w.joinedAt=null!==(S=n.joined_ts)&&void 0!==S?S:0,w._updateUnreadCount(null!==(T=n.unread_message_count)&&void 0!==T?T:0,null!==(A=n.unread_mention_count)&&void 0!==A?A:0),w.pinnedMessageIds=null!==(I=n.pinned_message_ids)&&void 0!==I?I:[],w.lastPinnedMessage=n.latest_pinned_message?bt(w._iid,i({channel_type:w.channelType},n.latest_pinned_message)):null,w}return e(n,t),Object.defineProperty(n.prototype,"isHidden",{get:function(){return this.hiddenState!==rs.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=C(this._unreadMemberStateMap),s=r.next();!s.done;s=r.next()){var i=v(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=C(this._undeliveredMemberStateMap),s=r.next();!s.done;s=r.next()){var i=v(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 r(s(i(i({},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 zt.payloadify(e)})),last_message:e.lastMessage?wt(e.lastMessage):null,inviter:e.inviter?c.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,pinned_message_ids:e.pinnedMessageIds,latest_pinned_message:e.lastPinnedMessage?wt(e.lastPinnedMessage):null})))},n.prototype._shouldUpdateLastMessageWith=function(e){return!(e instanceof Ct&&e.parentMessageId>0&&!e.replyToChannel)&&(!this.lastMessage||this.lastMessage.createdAt=0)if(this.myCountPreference===ts.ALL||this.myCountPreference===ts.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===ts.ALL||this.myCountPreference===ts.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 B(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState}))},n.prototype.createMessageCollection=function(e){return void 0===e&&(e={}),new Tr(this._iid,i({channel:this},e))},n.prototype.createMemberListQuery=function(e){return void 0===e&&(e={}),new Lr(this._iid,this.url,e)},n.prototype.createPinnedMessageListQuery=function(e){return void 0===e&&(e={}),new os(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===Ft.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 zt?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 Ct&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var r=j.of(this._iid).sdkState,s=e.createdAt,i=0;try{for(var a=C(this.members),o=a.next();!o.done;o=a.next()){var u=o.value;if(r.userId!==u.userId&&u.state===Ft.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 Ct?e.sender:null,i=[];return this.members.forEach((function(a){if(t||a.userId!==r.userId&&a.userId!==(null==s?void 0:s.userId)){var o=n._unreadMemberStateMap.get(a.userId);o&&o=t&&(e._typingStatus.delete(i),r=!0)})),r},n.prototype.refresh=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,s,i;return y(this,(function(a){switch(a.label){case 0:return e=j.of(this._iid),t=e.requestQueue,n=e.dispatcher,r=new ln({channelUrl:this.url}),[4,t.send(r)];case 1:return s=a.sent(),i=s.as(hn).channel,this._update(i),n.dispatch(new We({channels:[i],source:ze.REQUEST_CHANNEL})),[2,this]}}))}))},n.prototype.freeze=function(){return g(this,void 0,void 0,(function(){return y(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 We({channels:[this],source:ze.EVENT_CHANNEL_FROZEN,isWebSocketEventComing:!0})),[2]}}))}))},n.prototype.unfreeze=function(){return g(this,void 0,void 0,(function(){return y(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 We({channels:[this],source:ze.EVENT_CHANNEL_UNFROZEN,isWebSocketEventComing:!0})),[2]}}))}))},n.prototype.updateChannel=function(e){return g(this,void 0,void 0,(function(){var t,n,r,s,a,o,u;return y(this,(function(c){switch(c.label){case 0:return t=i(i({},Ar),e),f(function(e){return b("string",e.coverUrl,!0)&&(M(e.coverImage)||b("string",e.coverImage,!0))&&b("boolean",e.isDistinct,!0)&&b("boolean",e.isPublic,!0)&&b("boolean",e.isDiscoverable,!0)&&b("string",e.accessCode,!0)&&b("string",e.name,!0)&&b("string",e.data,!0)&&b("string",e.customType,!0)&&E("string",e.operatorUserIds,!0)&&b("number",e.messageSurvivalSeconds,!0)}(t)).throw(_.invalidParameters),n=j.of(this._iid),r=n.dispatcher,s=n.requestQueue,a=new Pr(i({channelUrl:this.url},t)),[4,s.send(a)];case 1:return o=c.sent(),u=o.as(Rr).channel,this._update(u),r.dispatch(new We({channels:[u],source:ze.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),[2,this]}}))}))},n.prototype.invite=function(e){return g(this,void 0,void 0,(function(){return y(this,(function(t){return f(e.every((function(e){return e instanceof c}))).throw(_.invalidParameters),[2,this.inviteWithUserIds(e.map((function(e){return e.userId})))]}))}))},n.prototype.inviteWithUserIds=function(e){return g(this,void 0,void 0,(function(){var t,n,r,s,i,a;return y(this,(function(o){switch(o.label){case 0:return f(E("string",e)).throw(_.invalidParameters),t=j.of(this._iid),n=t.dispatcher,r=t.requestQueue,s=new Pn({channelUrl:this.url,userIds:e}),[4,r.send(s)];case 1:return i=o.sent(),a=i.as(Rn).channel,this._update(a),n.dispatch(new We({channels:[a],source:ze.EVENT_CHANNEL_INVITED,isWebSocketEventComing:!0})),[2,this]}}))}))},n.prototype.join=function(e){return g(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return y(this,(function(u){switch(u.label){case 0:return f(b("string",e,!0)).throw(_.invalidParameters),t=j.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new In({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(i)];case 1:return a=u.sent(),(o=a.as(wn).channel).myMemberState=this.myMemberState=Ft.JOINED,this._update(o),n.dispatch(new We({channels:[o],source:ze.EVENT_CHANNEL_JOINED,isWebSocketEventComing:!0})),[2,this]}}))}))},n.prototype.leave=function(e){return void 0===e&&(e=!1),g(this,void 0,void 0,(function(){var t,n,r,s;return y(this,(function(i){switch(i.label){case 0:return t=j.of(this._iid),n=t.sdkState,r=t.requestQueue,s=new Dn({channelUrl:this.url,userId:n.userId,shouldRemoveOperatorStatus:e}),[4,r.send(s)];case 1:return i.sent(),this.myMemberState=Ft.NONE,[2]}}))}))},n.prototype.acceptInvitation=function(e){return g(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return y(this,(function(u){switch(u.label){case 0:return f(b("string",e,!0)).throw(_.invalidParameters),t=j.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new Dr({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(i)];case 1:return a=u.sent(),(o=a.as(kr).channel).myMemberState=this.myMemberState=Ft.JOINED,this._update(o),n.dispatch(new We({channels:[o],source:ze.EVENT_CHANNEL_ACCEPTED_INVITE,isWebSocketEventComing:!0})),[2,this]}}))}))},n.prototype.declineInvitation=function(){return g(this,void 0,void 0,(function(){var e,t,n,r;return y(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=Ft.NONE,[2,this]}}))}))},n.prototype.sendUserMessage=function(e){var n=this,r=new Dt,s=j.of(this._iid).dispatcher,i=nt.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===rs.HIDDEN_ALLOW_AUTO_UNHIDE&&(n.hiddenState=rs.UNHIDDEN),i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),rr.of(n._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),s.dispatch(new We({channels:[n],source:ze.EVENT_MESSAGE_SENT})),r._trigger(null,e)})),r},n.prototype.updateUserMessage=function(e,n){return g(this,void 0,void 0,(function(){var r,s,i,a,o=this;return y(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&&(rr.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),r.dispatch(new We({channels:[this],source:a?ze.EVENT_PINNED_MESSAGE_UPDATED:ze.EVENT_MESSAGE_UPDATED}))),a&&rr.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),r.dispatch(new L({messages:[s],source:J.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},n.prototype._autoResendUserMessage=function(e){var n=this,r=new Dt,s=j.of(this._iid).dispatcher,i=nt.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=rr.of(n._iid);i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),t.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),s.dispatch(new We({channels:[n],source:ze.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=nt.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=rr.of(n._iid);i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),t.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),s.dispatch(new We({channels:[n],source:ze.EVENT_MESSAGE_SENT})),r._trigger(null,e)})),r},n.prototype.sendMultipleFilesMessage=function(e){var n=this,r=new Lt,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=rr.of(n._iid);n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),t.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),s.dispatch(new We({channels:[n],source:ze.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 g(this,void 0,void 0,(function(){var r,s,i,a,o=this;return y(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&&(rr.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),r.dispatch(new We({channels:[this],source:a?ze.EVENT_PINNED_MESSAGE_UPDATED:ze.EVENT_MESSAGE_UPDATED}))),a&&rr.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),r.dispatch(new L({messages:[s],source:J.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},n.prototype._autoResendFileMessage=function(e){var n=this,r=new Dt,s=j.of(this._iid).dispatcher,i=nt.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=rr.of(n._iid);i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),t.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),s.dispatch(new We({channels:[n],source:ze.EVENT_MESSAGE_SENT})),r._trigger(null,e)})),r},n.prototype.deleteMessage=function(e){return g(this,void 0,void 0,(function(){return y(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 Ct&&j.of(this._iid).dispatcher.dispatch(new I({reqId:e.reqId,source:J.EVENT_MESSAGE_DELETED})),[2]}}))}))},n.prototype.hide=function(e){return g(this,void 0,void 0,(function(){var t,n,r,s,a,o,u,c;return y(this,(function(l){switch(l.label){case 0:return t=i(i({},Wn),e),f(function(e){return b("boolean",e.hidePreviousMessages,!0)&&b("boolean",e.allowAutoUnhide,!0)}(t)).throw(_.invalidParameters),n=j.of(this._iid),r=n.dispatcher,s=n.sdkState,a=n.requestQueue,o=new zn(i({channelUrl:this.url,userId:s.userId},t)),[4,a.send(o)];case 1:return u=l.sent(),c=u.as(jn).messageOffsetTimestamp,this.hiddenState=t.allowAutoUnhide?rs.HIDDEN_ALLOW_AUTO_UNHIDE:rs.HIDDEN_PREVENT_AUTO_UNHIDE,t.hidePreviousMessages&&this._updateUnreadCount(0,0),c&&(this.messageOffsetTimestamp=c),r.dispatch(new We({channels:[this],source:ze.EVENT_CHANNEL_HIDDEN,isWebSocketEventComing:!0})),[2,this]}}))}))},n.prototype.unhide=function(){return g(this,void 0,void 0,(function(){var e,t,n,r;return y(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=rs.UNHIDDEN,t.dispatch(new We({channels:[this],source:ze.EVENT_CHANNEL_UNHIDDEN,isWebSocketEventComing:!0})),[2,this]}}))}))},n.prototype.delete=function(){return g(this,void 0,void 0,(function(){var e,t;return y(this,(function(n){switch(n.label){case 0:return e=j.of(this._iid).requestQueue,t=new Fr({channelUrl:this.url}),[4,e.send(t)];case 1:return n.sent(),[2]}}))}))},n.prototype.markAsRead=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,o=this;return y(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 Hn({channelUrl:this.url}),[4,r.send(s)];case 1:return i=u.sent(),a=i.as(Gn).readStatus,this._updateUnreadMemberState(t.userId,a.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),rr.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)}))),n.dispatch(new We({channels:[this],source:ze.EVENT_CHANNEL_READ})),[2]}}))}))},n.prototype.markAsDelivered=function(){return g(this,void 0,void 0,(function(){var e,t,n,r;return y(this,(function(s){switch(s.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Vn({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s.sent(),[2]}}))}))},n.prototype.startTyping=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,s;return y(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 Kn({channelUrl:this.url,time:this._typingStarted}),t.send(s)),[2]}))}))},n.prototype.endTyping=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,s;return y(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 Jn({channelUrl:this.url,time:this._typingStarted}),t.send(s)),[2]}))}))},n.prototype.createScheduledUserMessage=function(e){e=i(i({},rt),e),f(st(e)).throw(_.invalidParameters);var t=new Dt;return this._createScheduledUserMessage(e,t),t},n.prototype.updateScheduledUserMessage=function(e,t){return g(this,void 0,void 0,(function(){var n,r,s,a;return y(this,(function(o){switch(o.label){case 0:return n=i(i({},Br),t),f(function(e){return Fe(e)&&b("number",e.scheduledAt,!0)}(n)).throw(_.invalidParameters),r=j.of(this._iid).requestQueue,s=new jr(i({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,r.send(s)];case 1:return a=o.sent(),[2,a.as(Oe).message]}}))}))},n.prototype.createScheduledFileMessage=function(e){var t=this;e=i(i({},it),e),f(at(e)).throw(_.invalidParameters);var n=Date.now(),r=this._generateRequestId(),s=new Dt;return pe(He).then((function(){var i=t._createPendingScheduledFileMessage(e,r,n);Y((function(){return g(t,void 0,void 0,(function(){return y(this,(function(e){return[2,s._trigger(null,i)]}))}))}))})),M(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return t._createScheduledFileMessage(e,s,r,n)})):this._createScheduledFileMessage(e,s,r,n),s},n.prototype.updateScheduledFileMessage=function(e,t){return g(this,void 0,void 0,(function(){var n,r,s;return y(this,(function(a){switch(a.label){case 0:return n=i(i({},qr),t),f(function(e){return Pe(e)&&b("number",e.scheduledAt,!0)&&(M(e.file)||b("string",e.fileUrl))&&b("string",e.fileName,!0)&&b("string",e.mimeType,!0)&&b("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return b("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(n)).throw(_.invalidParameters),M(n.file)?[4,this._uploadFileAndUpdateParams(n)]:[3,2];case 1:a.sent(),a.label=2;case 2:return r=new Wr(i({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,j.of(this._iid).requestQueue.send(r)];case 3:return s=a.sent(),[2,s.as(zr).message]}}))}))},n.prototype.cancelScheduledMessage=function(e){return g(this,void 0,void 0,(function(){var t;return y(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.sendScheduledMessageNow=function(e){return g(this,void 0,void 0,(function(){var t;return y(this,(function(n){switch(n.label){case 0:return t=new Kr({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 g(this,void 0,void 0,(function(){var e,t,n,r,s,i;return y(this,(function(a){switch(a.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Xr({userId:t.userId,channelUrl:this.url}),[4,n.send(r)];case 1:return s=a.sent(),i=s.as(Zr).pushTriggerOption,this.myPushTriggerOption=i,[2,i]}}))}))},n.prototype.setMyPushTriggerOption=function(e){return g(this,void 0,void 0,(function(){var t,n,r,s,i,o,u;return y(this,(function(c){switch(c.label){case 0:return f(a(fe,e)).throw(_.invalidParameters),t=j.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new Yr({userId:r.userId,channelUrl:this.url,pushTriggerOption:e}),[4,s.send(i)];case 1:return o=c.sent(),u=o.as(Jr).pushTriggerOption,this.myPushTriggerOption=u,n.dispatch(new We({channels:[this],source:ze.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),[2,u]}}))}))},n.prototype.setMyCountPreference=function(e){return g(this,void 0,void 0,(function(){var t,n,r,s,i,o,u;return y(this,(function(c){switch(c.label){case 0:return f(a(ts,e)).throw(_.invalidParameters),t=j.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new Or({channelUrl:this.url,userId:r.userId,countPreference:e}),[4,s.send(i)];case 1:return o=c.sent(),u=o.as(Hr).countPreference,this.myCountPreference=u,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),n.dispatch(new We({channels:[this],source:ze.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),[2,u]}}))}))},n.prototype.resetMyHistory=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,s,i;return y(this,(function(a){switch(a.label){case 0:return e=j.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new Gr({channelUrl:this.url}),[4,n.send(r)];case 1:return s=a.sent(),i=s.as(Vr).messageOffsetTimestamp,this.messageOffsetTimestamp=i,t.dispatch(new We({channels:[this],source:ze.EVENT_CHANNEL_RESET_HISTORY,isWebSocketEventComing:!0})),[2,this]}}))}))},n.prototype.pinMessage=function(e){return g(this,void 0,void 0,(function(){var t,n;return y(this,(function(r){switch(r.label){case 0:return f(b("number",e)&&e>0).throw(_.invalidParameters),t=j.of(this._iid).requestQueue,n=new $r({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(n)];case 1:return r.sent(),[2]}}))}))},n.prototype.unpinMessage=function(e){return g(this,void 0,void 0,(function(){var t,n;return y(this,(function(r){switch(r.label){case 0:return f(b("number",e)&&e>0).throw(_.invalidParameters),t=j.of(this._iid).requestQueue,n=new es({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(n)];case 1:return r.sent(),[2]}}))}))},n.prototype._uploadFileAndUpdateParams=function(e){return g(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,c,l,h;return y(this,(function(d){switch(d.label){case 0:return M(e.file)?(t=j.of(this._iid).requestQueue,n=new Pt({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(kt),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}(xe),ls={},hs=function(){function e(e){var t=e._iid,n=e.limit,r=void 0===n?100:n,s=this;this.ref=0,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 ir(l,(function(){return g(s,void 0,void 0,(function(){var e,t,n,r,s,i,a,o,u,l;return y(this,(function(h){switch(h.label){case 0:return e={hasNext:!0,nextToken:""},[4,this.loadMetadata()];case 1:if(h.sent(),c.debug("channel background sync from",null===(a=this._metadata)||void 0===a?void 0:a.token),null===(o=this._metadata)||void 0===o?void 0:o.completed)return[3,9];h.label=2;case 2:return h.trys.push([2,5,,8]),[4,rr.of(this._iid).getMyGroupChannels(null!==(l=null===(u=this._metadata)||void 0===u?void 0:u.token)&&void 0!==l?l:"",{includeEmpty:!0,order:Ge.CHRONOLOGICAL},this._limit,ze.SYNC_CHANNEL_BACKGROUND)];case 3:return t=h.sent(),n=t.channels,r=t.token,e.hasNext=n.length>=this._limit&&!!r,e.nextToken=r,this._metadata&&(this._metadata.token=r,(i=this._metadata.range).extends.apply(i,m([],v(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 h.sent(),[3,8];case 5:return s=h.sent(),c.debug("channel background sync error",s),s instanceof _&&s.isInvalidTokenError?[4,this.clearMetaData()]:[3,7];case 6:h.sent(),h.label=7;case 7:throw s;case 8:return[3,10];case 9:e.hasNext=!1,e.nextToken="",h.label=10;case 10:return[2,e]}}))}))})),this._connectionEventContext=u.on((function(e){if(e instanceof ee)if(e.stateType===te.CONNECTED)s.resume();else s.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])},Object.defineProperty(e.prototype,"range",{get:function(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new er({})},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 g(this,void 0,void 0,(function(){var e;return y(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 er(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return g(this,void 0,void 0,(function(){return y(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 g(this,void 0,void 0,(function(){return y(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=void 0,[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 ls[this._iid])},e}(),ds={},ps=function(){function e(e){var t=e._iid,n=this;this.ref=0,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 ir(u,(function(){return g(n,void 0,void 0,(function(){var e,t,n,r,s,a,o,u;return y(this,(function(c){switch(c.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:c.sent(),i.debug("channel changelog sync from",null===(a=this._metadata)||void 0===a?void 0:a.token),c.label=2;case 2:return c.trys.push([2,5,,8]),[4,rr.of(this._iid).getMyGroupChannelChangeLogs(null!==(u=null===(o=this._metadata)||void 0===o?void 0:o.token)&&void 0!==u?u:"",{includeEmpty:!0},ze.SYNC_CHANNEL_CHANGELOGS)];case 3:return t=c.sent(),n=t.hasMore,r=t.token,e.hasNext=n,e.nextToken=r,this._metadata&&(this._metadata.token=r),i.debug("channel changelog sync progress",e),[4,this.saveMetadata()];case 4:return c.sent(),[3,8];case 5:return s=c.sent(),i.debug("channel changelog sync error",s),s instanceof _&&s.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:c.sent(),c.label=7;case 7:throw s;case 8:return[2,e]}}))}))})),this._connectionEventContext=o.on((function(e){if(e instanceof ee)if(e.stateType===te.CONNECTED)n.resume();else n.pause()}))}return e.of=function(t){return ds[t]||(ds[t]=new e({_iid:t})),ds[t].ref++,ds[t]},e.clear=function(e){ds[e]&&(ds[e].close(),delete ds[e])},e.prototype.loadMetadata=function(){return g(this,void 0,void 0,(function(){var e,t,n,r;return y(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 g(this,void 0,void 0,(function(){return y(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 g(this,void 0,void 0,(function(){return y(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=void 0,[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 ds[this._iid])},e}(),fs=function(){function e(e,t){var n=t.filter,r=t.order,s=t.limit,i=this;this.channels=[],this._iid=e,this._key="gcc-".concat(oe()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this.filter=null!=n?n:new Kt,this.order=null!=r?r:Ge.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=s?s:ye;var a=j.of(this._iid),o=a.sdkState,u=a.cacheContext,c=a.dispatcher;u.localCacheEnabled&&(this._backgroundSync=hs.of(e),this._backgroundSync.resume()),this._changelogSync=ps.of(e),this._changelogSync.resume(),rr.of(this._iid).subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){if(tt(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 ie({type:ae.FEATURE_LOCALCACHE,data:{use_local_cache:u.localCacheEnabled,collection_interface:{group_channel:!0}}})),c.on((function(e){e instanceof ee&&(e.stateType===te.CONNECTED?i._isGetRemoteChannelsSucceeded||g(i,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,this._revokeLoadMore()];case 1:return e.sent(),[2]}}))})):e.stateType===te.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=C(e),d=h.next();!d.done;d=h.next()){var p=d.value,f=mr(this.channels,p);f>=0&&this.channels.splice(f,1);var _=vr(this.channels,p,this.order).place;if(f<0)_===this.channels.length?!n&&this._hasMore||(u.push(p),this.channels.push(p)):(u.push(p),this.channels.splice(_,0,p));else switch(t){case ze.EVENT_CHANNEL_UPDATED:case ze.EVENT_MESSAGE_RECEIVED:case ze.SYNC_CHANNEL_CHANGELOGS:case ze.EVENT_MESSAGE_SENT:_!==f&&this._hasMore&&_===this.channels.length?l.push(p):(this.channels.splice(_,0,p),c.push(p));break;default:this.channels.splice(_,0,p),c.push(p)}}}catch(e){r={error:e}}finally{try{d&&!d.done&&(s=h.return)&&s.call(h)}finally{if(r)throw r.error}}if(l.length>0)try{for(var m=C(l),v=m.next();!v.done;v=m.next()){p=v.value;var E=mr(this.channels,p);-1!==E&&this.channels.splice(E,1)}}catch(e){i={error:e}}finally{try{v&&!v.done&&(a=m.return)&&a.call(m)}finally{if(i)throw i.error}}tt(t)&&Y((function(){return g(o,void 0,void 0,(function(){var e,n,r,s;return y(this,(function(i){return e=new ar(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=C(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 tt(t)&&i.length>0&&Y((function(){return g(s,void 0,void 0,(function(){var e,n;return y(this,(function(r){return e=new ar(t),(null===(n=this._handler)||void 0===n?void 0:n.onChannelsDeleted)&&this._handler.onChannelsDeleted(e,i),[2]}))}))})),i},e.prototype._getLocalChannels=function(){return g(this,void 0,void 0,(function(){var e,t;return y(this,(function(n){switch(n.label){case 0:return e=rr.of(this._iid),t=this.channels.length>0?function(e,t){var n,r,s,i;switch(t){case Ge.LATEST_LAST_MESSAGE:return null!==(r=null===(n=e.lastMessage)||void 0===n?void 0:n.createdAt)&&void 0!==r?r:e.createdAt;case Ge.CHRONOLOGICAL:return e.createdAt;case Ge.CHANNEL_NAME_ALPHABETICAL:return e.name;default:return null!==(i=null===(s=e.lastMessage)||void 0===s?void 0:s.createdAt)&&void 0!==i?i:e.createdAt}}(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:void 0)];case 1:return[2,n.sent()]}}))}))},e.prototype._getRemoteChannels=function(){return g(this,void 0,void 0,(function(){var e,t,n;return y(this,(function(r){switch(r.label){case 0:return[4,rr.of(this._iid).getMyGroupChannels(this._token,s(i(i({},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 g(this,void 0,void 0,(function(){var e;return y(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,ze.REQUEST_CHANNEL,!0),[3,4];case 3:return t.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,4];case 4:return[2]}}))}))},e.prototype.loadMore=function(){return g(this,void 0,void 0,(function(){var e,t,n=this;return y(this,(function(r){switch(r.label){case 0:if(this._isDisposed)throw new _({code:X.COLLECTION_DISPOSED,message:"Collection has been disposed."});return this._hasMore?(e=j.of(this._iid).cacheContext,t=[],e.localCacheEnabled&&this._backgroundSync.completed?[4,U((function(){return g(n,void 0,void 0,(function(){return y(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,ze.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(),rr.of(this._iid).unsubscribeGroupChannelEvent(this._key))},e}(),_s=function(t){function n(e){var n=this,i=e.token,a=e.limit,o=e.order,u=e.includeEmpty,c=e.membershipFilter,l=e.channelNameContainsFilter,h=e.channelUrlsFilter,d=e.customTypesFilter,p=e.customTypeStartsWithFilter,f=e.superChannelFilter,_=e.metadataOrderKeyFilter,m=e.metadataKey,v=e.metadataValues,g=e.metadataValueStartsWith,y=e.includeFrozen,C=e.includeMetaData;return(n=t.call(this)||this).method=D.GET,n.path=O,n.params=r(s({token:i,limit:a,order:o,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:u,public_mode:xt.PUBLIC,public_membership_mode:c,name_contains:l,channel_urls:h,custom_types:d,custom_type_startswith:p,super_mode:f,metadata_order_key:_,metadata_key:m,metadata_values:v,metadata_value_startswith:g,show_frozen:y,show_metadata:C})),n}return e(n,t),n}(R),ms=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.channels=[];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 cs(e,t)}))),r.ts="number"==typeof a?a:0,r}return e(n,t),n}(F);!function(e){e.ALL="all",e.JOINED="joined"}(us||(us={}));var vs=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=us.ALL,v.superChannelFilter=Ht.ALL,v.metadataKey=null,v.metadataValues=null,v.metadataOrderKeyFilter=null,v.metadataValueStartsWith=null,v.order=ot.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:us.ALL,v.superChannelFilter=null!==(h=n.superChannelFilter)&&void 0!==h?h:Ht.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:ot.CHRONOLOGICAL,v}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&b("boolean",this.includeEmpty)&&b("boolean",this.includeFrozen)&&b("boolean",this.includeMetaData)&&b("string",this.channelNameContainsFilter,!0)&&E("string",this.channelUrlsFilter,!0)&&E("string",this.customTypesFilter,!0)&&b("string",this.customTypeStartsWithFilter,!0)&&a(us,this.membershipFilter)&&a(Ht,this.superChannelFilter)&&a(ot,this.order)&&b("string",this.metadataOrderKeyFilter,!0)&&b("string",this.metadataKey,!0)&&E("string",this.metadataValues,!0)&&b("string",this.metadataValueStartsWith,!0)},n.prototype.next=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,a,o,u,c;return y(this,(function(l){switch(l.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 _s(s(i(i({},this),{token:this._token}))),[4,n.send(r)]):[3,2]):[3,5];case 1:return a=l.sent(),o=a.as(ms),u=o.channels,c=o.token,this._token=c,this._hasNext=!!c,this._isLoading=!1,[2,u];case 2:return[2,e];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},n}(W),gs=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}(gt)),ys=function(t){function n(e){var n=this,i=e.token,a=e.limit,o=e.order,u=e.reverse,c=e.channelUrl,l=e.messageTypeFilter,h=e.scheduledStatus;return(n=t.call(this)||this).method=D.GET,n.path="".concat(H),n.params=r(s({token:i,limit:a,reverse:u,channel_url:c,order:o,message_type:l,status:h})),n}return e(n,t),n}(R),Cs=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.scheduledMessages=[];var s=n.next,i=n.scheduled_messages;return r.token=s,r.scheduledMessages=i.map((function(t){return bt(e,t)})),r}return e(n,t),n}(F),Es=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=N.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:N.ALL,u}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&b("string",this.channelUrl,!0)&&(a(ut,this.order)||null===this.order)&&b("boolean",this.reverse)&&(E(yt,this.scheduledStatus)||null===this.scheduledStatus)&&a(N,this.messageTypeFilter)},n.prototype.next=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,a,o;return y(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 ys(s(i(i({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=u.sent(),r=n.as(Cs),a=r.scheduledMessages,o=r.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},n}(W),bs=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 rr(e,{sdkState:r,cacheContext:c,dispatcher:s,sessionManager:i,requestQueue:a,logger:o})},n.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new fs(this._iid,e)},n.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new $n(this._iid,e)},n.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new vs(this._iid,e)},n.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new Es(this._iid,e)},n.prototype.addGroupChannelHandler=function(e,t){f(b("string",e)&&t instanceof gs).throw(_.invalidParameters),this._manager.addHandler(e,t)},n.prototype.removeGroupChannelHandler=function(e){f(b("string",e)).throw(_.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 g(this,void 0,void 0,(function(){return y(this,(function(t){return f(b("string",e)).throw(_.invalidParameters),[2,this._manager.getChannel(e)]}))}))},n.prototype.getChannelWithoutCache=function(e){return g(this,void 0,void 0,(function(){return y(this,(function(t){return f(b("string",e)).throw(_.invalidParameters),[2,this._manager.getChannelWithoutCache(e)]}))}))},n.prototype.getMyGroupChannelChangeLogsByToken=function(e,t){return void 0===t&&(t={}),g(this,void 0,void 0,(function(){var n;return y(this,(function(r){switch(r.label){case 0:return n=i(i({},Zt),t),f(b("string",e)&&$t(n)).throw(_.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,r.sent()]}}))}))},n.prototype.getMyGroupChannelChangeLogsByTimestamp=function(e,t){return void 0===t&&(t={}),g(this,void 0,void 0,(function(){var n;return y(this,(function(r){switch(r.label){case 0:return n=i(i({},Zt),t),f(b("number",e)&&$t(n)).throw(_.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,r.sent()]}}))}))},n.prototype.getGroupChannelCount=function(e){return g(this,void 0,void 0,(function(){var t;return y(this,(function(n){return t=i(i({},en),e),f(tn(t)).throw(_.invalidParameters),[2,this._manager.getGroupChannelCount(t)]}))}))},n.prototype.getUnreadItemCount=function(e){return void 0===e&&(e={}),g(this,void 0,void 0,(function(){return y(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 g(this,void 0,void 0,(function(){return y(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={}),g(this,void 0,void 0,(function(){return y(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={}),g(this,void 0,void 0,(function(){return y(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={}),g(this,void 0,void 0,(function(){var t;return y(this,(function(n){return t=i(i({},Jt),e),f(Xt(t)).throw(_.invalidParameters),[2,this._manager.createChannel(t)]}))}))},n.prototype.createDistinctChannelIfNotExist=function(e){return void 0===e&&(e={}),g(this,void 0,void 0,(function(){var t;return y(this,(function(n){return t=i(i({},Jt),e),f(Xt(t)).throw(_.invalidParameters),t&&(t.isDistinct=!0),[2,this.createChannel(t)]}))}))},n.prototype.createChannelWithUserIds=function(e,t,n,r,s,a){return void 0===t&&(t=!1),void 0===s&&(s=""),void 0===a&&(a=""),g(this,void 0,void 0,(function(){var o;return y(this,(function(u){return o=i(i({},Jt),{invitedUserIds:e,isDistinct:t,name:n,data:s,customType:a}),"string"==typeof r?o.coverUrl=r:o.coverImage=r,[2,this.createChannel(o)]}))}))},n.prototype.markAsReadAll=function(){return g(this,void 0,void 0,(function(){return y(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},n.prototype.markAsReadWithChannelUrls=function(e){return g(this,void 0,void 0,(function(){return y(this,(function(t){return f(E("string",e)).throw(_.invalidParameters),this._manager.markAsReadWithChannelUrls(e),[2]}))}))},n.prototype.markAsDelivered=function(e){return g(this,void 0,void 0,(function(){return y(this,(function(t){switch(t.label){case 0:return f(b("string",e)).throw(_.invalidParameters),[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},n}(me);export{ts as CountPreference,cs as GroupChannel,fs as GroupChannelCollection,ar as GroupChannelEventContext,Kt as GroupChannelFilter,gs as GroupChannelHandler,$n as GroupChannelListQuery,bs as GroupChannelModule,Wt as GroupChannelSearchField,Vt as HiddenChannelFilter,rs as HiddenState,zt as Member,Nr as MemberListOrder,Lr as MemberListQuery,Ft as MemberState,Ur as MemberStateFilter,us as MembershipFilter,Tr as MessageCollection,Sr as MessageCollectionInitHandler,sr as MessageCollectionInitPolicy,or as MessageEventContext,Mr as MutedMemberFilter,ns as MutedState,Ot as MyMemberStateFilter,qt as OperatorFilter,ss as PinnedMessage,os as PinnedMessageListQuery,xt as PublicChannelFilter,vs as PublicGroupChannelListQuery,Bt as QueryType,jt as ReadStatus,Es as ScheduledMessageListQuery,Ht as SuperChannelFilter,Gt as UnreadChannelFilter,Qt as UnreadItemKey}; +import{_ as e,e as r,u as s,g as i,M as a,X as o,Q as u,U as c,a0 as h,aF as d,t as f,S as _,r as v,s as m,b as g,c as y,K as C,m as E,a as b,i as M,a7 as N,J as S,aE as U,aG as T,ax as A,aH as I,ak as w,aj as L,A as D,d as k,f as F,h as R,aI as x,ah as O,aJ as H,aa as V,W as q,a3 as B,B as W,w as z,V as j,R as Q,aD as K,z as Y,ai as J,ad as X,aK as Z,E as $,x as ee,y as te,ag as ne,ab as re,aL as se,aM as ie,aN as ae,p as oe,a5 as ue,aO as ce,am as le,a4 as he,aC as de,ae as pe,N as fe,n as _e,an as ve}from"./lib/__bundle-087816c3.js";export{ai as MessageEventSource}from"./lib/__bundle-087816c3.js";import{g as me,N as ge,p as ye,q as Ce,r as Ee,t as be,u as Me,w as Ne,x as Se,y as Ue,P as Te,z as Ae,A as Ie,C as we,E as Le,D as De,G as ke,H as Pe,I as Fe,J as Re,f as xe,K as Oe,L as He}from"./lib/__bundle-50274a15.js";import{G as Ge,g as Ve,D as qe,l as Be,m as We,n as ze,j as je,i as Qe,o as Ke,R as Ye,p as Je,k as Xe,U as Ze,e as $e,f as et,s as tt,d as nt,S as rt,v as st,q as it,r as at,P as ot,t as ut}from"./lib/__bundle-1ef675e5.js";export{n as GroupChannelEventSource,G as GroupChannelListOrder,p as MessageFilter,P as PublicGroupChannelListOrder,t as ScheduledMessageListOrder}from"./lib/__bundle-1ef675e5.js";import{C as ct,a as lt,O as ht,P as dt,M as pt,T as ft,R as _t,U as vt,A as mt,B as gt}from"./lib/__bundle-dddddac5.js";import{l as yt,S as Ct,I as Et,p as bt,U as Mt,F as Nt,m as St,c as Ut,T as Tt,d as At,A as It,n as wt,g as Lt,h as Dt,o as kt,q as Pt}from"./lib/__bundle-80fd264e.js";export{l as ScheduledStatus}from"./lib/__bundle-80fd264e.js";import{b as Ft}from"./lib/__bundle-8f39cad4.js";var Rt;!function(e){e.NONE="none",e.JOINED="joined",e.INVITED="invited",e.LEFT="left"}(Rt||(Rt={}));var xt,Ot,Ht,Gt,Vt,qt,Bt,Wt,zt=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=a(Rt,n.state)?n.state:null,r.role=a(o,n.role)?n.role:null,"boolean"==typeof n.is_muted&&(r.isMuted=n.is_muted),"boolean"==typeof n.is_blocked_by_me&&(r.isBlockedByMe=n.is_blocked_by_me),"boolean"==typeof n.is_blocking_me&&(r.isBlockingMe=n.is_blocking_me),r}return e(n,t),n.payloadify=function(e){return r(s(i(i({},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})))},n}(me),jt=function(t){function n(e,n){var r,s,i=this;return(i=t.call(this,e)||this).channelUrl=null!==(r=n.channel_url)&&void 0!==r?r:"",i.channelType=null!==(s=n.channel_type)&&void 0!==s?s:u.GROUP,i.reader=new c(i._iid,n.user),i.readAt=n.ts,i}return e(n,t),n}(h);!function(e){e.ALL="all",e.PUBLIC="public",e.PRIVATE="private"}(xt||(xt={})),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"}(Ot||(Ot={})),function(e){e.ALL="all",e.SUPER="super",e.NON_SUPER="nonsuper",e.BROADCAST_ONLY="broadcast_only",e.EXCLUSIVE_ONLY="exclusive_only"}(Ht||(Ht={})),function(e){e.ALL="all",e.UNREAD_MESSAGE="unread_message"}(Gt||(Gt={})),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"}(Vt||(Vt={})),function(e){e.ALL="all",e.OPERATOR="operator",e.NONOPERATOR="nonoperator"}(qt||(qt={})),function(e){e.AND="AND",e.OR="OR"}(Bt||(Bt={})),function(e){e.MEMBER_NICKNAME="member_nickname",e.CHANNEL_NAME="channel_name"}(Wt||(Wt={}));var Qt,Kt=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=Ot.ALL,this.customTypesFilter=null,this.channelUrlsFilter=null,this.superChannelFilter=Ht.ALL,this.publicChannelFilter=xt.ALL,this.customTypeStartsWithFilter=null,this.unreadChannelFilter=Gt.ALL,this.hiddenChannelFilter=Vt.UNHIDDEN,this.includeFrozen=!0}return e.prototype._isFriend=function(e){return!(!e||!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=Bt.AND),this._userIdsFilter={userIds:e,includeMode:t,queryType:n}},e.prototype.clone=function(){var t,n=new e;this.searchFilter&&n.setSearchFilter(this.searchFilter.fields,null!==(t=this.searchFilter.query)&&void 0!==t?t:void 0),this.userIdsFilter&&n.setUserIdsFilter(this.userIdsFilter.userIds,this.userIdsFilter.includeMode,this.userIdsFilter.queryType);var r=JSON.parse(JSON.stringify(this));return Object.keys(r).forEach((function(e){n[e]=r[e]})),n},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 Wt.CHANNEL_NAME:return e.name.toLowerCase().includes(r.toLowerCase());case Wt.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 Bt.AND:if(a.some((function(e){return!c.includes(e)})))return!1;break;case Bt.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(!d(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 h=this.nicknameStartsWithFilter.toLowerCase();if(!e.members.some((function(e){return e.userId!==t&&e.nickname.toLowerCase().startsWith(h)})))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 Ot.JOINED:if("joined"!==e.myMemberState)return!1;break;case Ot.INVITED:if("invited"!==e.myMemberState)return!1;break;case Ot.INVITED_BY_FRIEND:if("invited"!==e.myMemberState||!this._isFriend(e.inviter))return!1;break;case Ot.INVITED_BY_NON_FRIEND:if("invited"!==e.myMemberState||this._isFriend(e.inviter))return!1}if(this.hiddenChannelFilter)switch(this.hiddenChannelFilter){case Vt.UNHIDDEN:if(e.isHidden||"unhidden"!==e.hiddenState)return!1;break;case Vt.HIDDEN:if(!e.isHidden)return!1;break;case Vt.HIDDEN_ALLOW_AUTO_UNHIDE:if(!e.isHidden||"hidden_allow_auto_unhide"!==e.hiddenState)return!1;break;case Vt.HIDDEN_PREVENT_AUTO_UNHIDE:if(!e.isHidden||"hidden_prevent_auto_unhide"!==e.hiddenState)return!1}if(this.unreadChannelFilter&&this.unreadChannelFilter===Gt.UNREAD_MESSAGE)if(0===e.unreadMessageCount)return!1;if(this.publicChannelFilter)switch(this.publicChannelFilter){case xt.PUBLIC:if(!e.isPublic)return!1;break;case xt.PRIVATE:if(e.isPublic)return!1}if(this.superChannelFilter)switch(this.superChannelFilter){case Ht.SUPER:if(!e.isSuper)return!1;break;case Ht.NON_SUPER:if(e.isSuper)return!1}return!0},e}(),Yt=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 f(!!e).throw(_.databaseError),e.collection(ge)},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),i(i({},e.serialize()),{lastMessageUpdatedAt:e.lastMessage?e.lastMessage.createdAt:0,syncIndex:t})},n.prototype._deserialize=function(e){return rr.of(this._iid).buildGroupChannelFromSerializedData(e)},Object.defineProperty(n.prototype,"channels",{get:function(){return v([],m(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(l&&l===e.url)return!1;break;case Ge.CHRONOLOGICAL:if(!i&&e.createdAt>t||i&&e.createdAtt||i&&e.lastMessageUpdatedAt0?[4,this.upsert(r)]:[3,2];case 1:y.sent(),y.label=2;case 2:return[2]}}))}))},n.prototype.block=function(e,t){return g(this,void 0,void 0,(function(){return y(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 g(this,void 0,void 0,(function(){return y(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=v([],m(this._channels.keys()),!1)),g(this,void 0,void 0,(function(){var n,r,s,i,a,o,u,c;return y(this,(function(l){switch(l.label){case 0:n=[],l.label=1;case 1:l.trys.push([1,6,7,8]),r=C(t),s=r.next(),l.label=2;case 2:return s.done?[3,5]:(i=s.value,[4,this.get(i)]);case 3:(null==(a=l.sent())?void 0:a._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}(h),Jt={invitedUserIds:void 0,channelUrl:void 0,coverUrl:void 0,coverImage:void 0,isDistinct:void 0,isSuper:void 0,isBroadcast:void 0,isExclusive:void 0,isPublic:void 0,isDiscoverable:void 0,isStrict:void 0,isEphemeral:void 0,accessCode:void 0,name:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,messageSurvivalSeconds:void 0},Xt=function(e){return E("string",e.invitedUserIds,!0)&&b("string",e.channelUrl,!0)&&b("string",e.coverUrl,!0)&&(M(e.coverImage)||b("string",e.coverImage,!0))&&b("boolean",e.isDistinct,!0)&&b("boolean",e.isSuper,!0)&&b("boolean",e.isBroadcast,!0)&&b("boolean",e.isExclusive,!0)&&b("boolean",e.isPublic,!0)&&b("boolean",e.isStrict,!0)&&b("boolean",e.isDiscoverable,!0)&&b("boolean",e.isEphemeral,!0)&&b("string",e.accessCode,!0)&&b("string",e.name,!0)&&b("string",e.data,!0)&&b("string",e.customType,!0)&&E("string",e.operatorUserIds,!0)&&b("number",e.messageSurvivalSeconds,!0)},Zt={customTypes:void 0,includeEmpty:!1,includeFrozen:!0},$t=function(e){return E("string",e.customTypes,!0)&&b("boolean",e.includeEmpty)&&b("boolean",e.includeFrozen)},en={myMemberStateFilter:Ot.ALL},tn=function(e){return a(Ot,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 nn={keys:[]},rn={channelCustomTypesFilter:void 0,superChannelFilter:Ht.ALL},sn={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:N.ALL},an=function(){function e(e){var t=e.groupChannelCache,n=e.messageCache,r=e.unsentMessageCache,s=e.dispatcher,i=this;this._observers=new Map,s.on((function(e){return g(i,void 0,void 0,(function(){var s,i,a,o,u,c,l,h,d,p,f,_,v,m,E=this;return y(this,(function(b){switch(b.label){case 0:if(!(e instanceof We))return[3,10];s=e.channels,f=e.source,_=e.isWebSocketEventComing,i=e.data,a=s.filter((function(e){return e instanceof cs})),o=t.filterOffsetChanged(a),b.label=1;case 1:b.trys.push([1,6,7,8]),u=C(o),c=u.next(),b.label=2;case 2:return c.done?[3,5]:(l=c.value,[4,n.removeUnderOffset(l.url,l.messageOffsetTimestamp)]);case 3:b.sent(),b.label=4;case 4:return c=u.next(),[3,2];case 5:return[3,8];case 6:return h=b.sent(),v={error:h},[3,8];case 7:try{c&&!c.done&&(m=u.return)&&m.call(u)}finally{if(v)throw v.error}return[7];case 8:return[4,t.upsert(a)];case 9:return d=b.sent(),_||this._broadcastUpdateEvent(d,f,i),[3,15];case 10:return e instanceof Be?(p=e.channelUrls,f=e.source,_=e.isWebSocketEventComing,[4,t.remove(p)]):[3,13];case 11:return b.sent(),[4,S((function(){return g(E,void 0,void 0,(function(){var e,t,s,i,a,o;return y(this,(function(u){switch(u.label){case 0:u.trys.push([0,6,7,8]),e=C(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 b.sent(),_||this._broadcastRemoveEvent(p,f),[3,15];case 13:return e instanceof qe?[4,t.fetch({token:Number.MAX_SAFE_INTEGER,limit:Number.MAX_SAFE_INTEGER})]:[3,15];case 14:b.sent(),b.label=15;case 15:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t,n){var r,s;try{for(var i=C(this._observers.values()),a=i.next();!a.done;a=i.next()){var o=a.value;o.onUpdate&&o.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=C(this._observers.values()),i=s.next();!i.done;i=s.next()){var a=i.value;a.onRemove&&a.onRemove(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype.subscribe=function(e,t){this._observers.set(e,t)},e.prototype.unsubscribe=function(e){this._observers.delete(e)},e.prototype.unsubscribeAll=function(){this._observers.clear()},e}(),on=function(){function e(e){var t=e.cacheContext,n=e.messageCache,r=e.unsentMessageCache,s=e.dispatcher,i=e.logger,a=this;this._observers=new Map,this._cacheContext=t,this._logger=i,s.on((function(e){return g(a,void 0,void 0,(function(){var t,s,i,a,o,u,c,l,h,d,p,f,_,v,m=this;return y(this,(function(C){switch(C.label){case 0:return e instanceof L?(t=e.messages,_=e.source,o=e.isWebSocketEventComing,s=t.filter((function(e){return e.messageId>0})),i=t.filter((function(e){return 0===e.messageId})),s.length>0?[4,S((function(){return g(m,void 0,void 0,(function(){return y(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 Ct?e.reqId:null})).filter((function(e){return null!==e})))];case 2:return e.sent(),[2]}}))}))}))]:[3,2]):[3,5];case 1:C.sent(),o||this._broadcastUpdateEvent(s,_),C.label=2;case 2:return i.length>0?[4,S((function(){return g(m,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,r.upsert(i)];case 1:return e.sent(),[2]}}))}))}))]:[3,4];case 3:C.sent(),o||this._broadcastUpdateEvent(i,_),C.label=4;case 4:return[3,21];case 5:return e instanceof w?(a=e.messageIds,_=e.source,o=e.isWebSocketEventComing,[4,S((function(){return g(m,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,n.remove(a)];case 1:return e.sent(),[2]}}))}))}))]):[3,7];case 6:return C.sent(),o||this._broadcastRemoveEvent(a,_),[3,21];case 7:return e instanceof I?(u=e.reqId,_=e.source,[4,S((function(){return g(m,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,r.remove([u])];case 1:return e.sent(),[2]}}))}))}))]):[3,9];case 8:return C.sent(),this._broadcastRemoveUnsentEvent(u,_),[3,21];case 9:return e instanceof A?(c=e.polls,_=e.source,this._cacheContext.localCacheEnabled?(l=c.map((function(e){return e.messageId})),[4,Promise.all(l.map((function(e){return n.get(e)})))]):[3,12]):[3,13];case 10:return(h=C.sent().filter((function(e){return e}))).length>0&&c.forEach((function(e){var t=h.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),[4,S((function(){return g(m,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,n.upsert(h)];case 1:return[2,e.sent()]}}))}))}))];case 11:C.sent(),C.label=12;case 12:return this._broadcastPollChangeLogEvent(c,_),[3,21];case 13:return e instanceof T?(d=e.event,_=e.source,[4,n.get(d.messageId)]):[3,17];case 14:return(p=C.sent())&&p.isUserMessage()&&p.poll&&p.poll.applyPollUpdateEvent(d)?[4,S((function(){return g(m,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,n.upsert([p])];case 1:return[2,e.sent()]}}))}))}))]:[3,16];case 15:C.sent(),C.label=16;case 16:return this._broadcastPollUpdateEvent(d,_),[3,21];case 17:return e instanceof U?(f=e.event,_=e.source,[4,n.get(f.messageId)]):[3,21];case 18:return(v=C.sent())&&v.isUserMessage()&&v.poll&&v.poll.applyPollVoteEvent(f)?[4,S((function(){return g(m,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,n.upsert([v])];case 1:return[2,e.sent()]}}))}))}))]:[3,20];case 19:C.sent(),C.label=20;case 20:this._broadcastPollVoteEvent(f,_),C.label=21;case 21:return[2]}}))}))}))}return e.prototype._broadcastUpdateEvent=function(e,t){var n,r;try{for(var s=C(this._observers.values()),i=s.next();!i.done;i=s.next()){var a=i.value;a.onUpdate&&a.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=C(this._observers.values()),i=s.next();!i.done;i=s.next()){var a=i.value;a.onPollChangeLogUpdate&&a.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=C(this._observers.values()),i=s.next();!i.done;i=s.next()){var a=i.value;a.onPollUpdate&&a.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=C(this._observers.values()),i=s.next();!i.done;i=s.next()){var a=i.value;a.onPollVote&&a.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=C(this._observers.values()),i=s.next();!i.done;i=s.next()){var a=i.value;a.onRemove&&a.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=C(this._observers.values()),i=s.next();!i.done;i=s.next()){var a=i.value;a.onRemoveUnsent&&a.onRemoveUnsent(e,t)}}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype.subscribe=function(e,t){this._observers.set(e,t)},e.prototype.unsubscribe=function(e){this._observers.delete(e)},e.prototype.unsubscribeAll=function(){this._observers.clear()},e}(),un=function(t){function n(e){var n=e.userId,a=e.ts,o=e.token,u=e.filter,c=t.call(this)||this,l=i(i({},Zt),u),h=l.customTypes,d=l.includeEmpty,p=l.includeFrozen;return c.method=D.GET,c.path="".concat(k,"/").concat(encodeURIComponent(n),"/my_group_channels/changelogs"),c.params=r(s({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:a||null,token:o,custom_types:h,show_empty:d,show_frozen:p})),c}return e(n,t),n}(F),cn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.updatedChannels=n.updated.map((function(t){return new cs(e,t)})),r.deletedChannelUrls=n.deleted,r.hasMore=n.has_more,r.token=n.next,r}return e(n,t),n}(R),ln=function(t){function n(e){var n=e.channelUrl,r=e.isInternalCall,s=t.call(this)||this;return s.method=D.GET,s.path="".concat(r?x:O,"/").concat(encodeURIComponent(n)),s.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},s}return e(n,t),n}(F),hn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new cs(e,n),r}return e(n,t),n}(R),dn={includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,channelUrlsFilter:void 0,customTypesFilter:void 0,customTypeStartsWithFilter:void 0,nicknameContainsFilter:void 0,nicknameStartsWithFilter:void 0,nicknameExactMatchFilter:void 0,channelNameContainsFilter:void 0,myMemberStateFilter:Ot.ALL,unreadChannelFilter:Gt.ALL,superChannelFilter:Ht.ALL,publicChannelFilter:xt.ALL,hiddenChannelFilter:Vt.ALL,userIdsFilter:{userIds:[],includeMode:!0,queryType:Bt.AND},searchFilter:{query:void 0,fields:[]},metadataKey:void 0,metadataValues:void 0,metadataOrderKeyFilter:void 0,metadataValueStartsWith:void 0,order:Ge.LATEST_LAST_MESSAGE},pn=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,v=e.channelNameContainsFilter,m=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,A=e.userIdsFilter;return(n=t.call(this)||this).method=D.GET,n.path="".concat(k,"/").concat(encodeURIComponent(s),"/my_group_channels"),n.params=r({token:i,limit:a,order:null!=o?o:dn.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=u?u:dn.includeEmpty,member_state_filter:null!=c?c:dn.myMemberStateFilter,super_mode:null!=l?l:dn.superChannelFilter,public_mode:null!=h?h:dn.publicChannelFilter,unread_filter:null!=d?d:dn.unreadChannelFilter,members_nickname_contains:p,members_nickname_startswith:f,members_nickname:_,name_contains:v,channel_urls:m,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),A&&A.userIds&&A.userIds.length>0&&(A.includeMode?(n.params.members_include_in=A.userIds,n.params.query_type=A.queryType.toUpperCase()):n.params.members_exactly_in=A.userIds),n}return e(n,t),n}(F),fn=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.channels=[];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 cs(e,t)}))),r.ts=null!=a?a:0,r}return e(n,t),n}(R),_n=function(t){function n(e){var n=e.userId,r=e.filter,s=t.call(this)||this,i=r.myMemberStateFilter;return s.method=D.GET,s.path="".concat(k,"/").concat(encodeURIComponent(n),"/group_channel_count"),s.params={state:null!=i?i:Ot.ALL},s}return e(n,t),n}(F),vn=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}(R),mn=function(t){function n(e){var n=e.userId,s=e.filter,i=t.call(this)||this,a=s.keys;return i.method=D.GET,i.path="".concat(k,"/").concat(encodeURIComponent(n),"/unread_item_count"),i.params=r({item_keys:a}),i}return e(n,t),n}(F),gn=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}(R),yn=function(t){function n(e){var n=e.userId,r=t.call(this)||this;return r.method=D.GET,r.path="".concat(k,"/").concat(encodeURIComponent(n),"/unread_channel_count"),r}return e(n,t),n}(F),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}(R),En=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=D.GET,s.path="".concat(k,"/").concat(encodeURIComponent(n),"/unread_message_count"),s.params={super_mode:null!=a?a:Ht.ALL,custom_types:i},s}return e(n,t),n}(F),bn=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}(R),Mn=function(t){function n(e){var n=e.channelUrl,r=e.scheduledStatus,s=e.messageTypeFilter,i=t.call(this)||this;return i.method=D.GET,i.path="".concat(H,"/count"),i.params={channel_url:n,status:Sn(r)},s&&(i.params.message_type=s),i}return e(n,t),n}(F),Nn=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}(R),Sn=function(e){if(!e)return[];var t=[];return e.forEach((function(e){switch(e){case yt.PENDING:t.push(Et.PENDING);break;case yt.SENT:t.push(Et.IN_QUEUE),t.push(Et.SENT);break;case yt.CANCELED:t.push(Et.CANCELED);break;case yt.FAILED:t.push(Et.FAILED)}})),t},Un=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,d=e.isExclusive,p=e.isDiscoverable,f=e.isStrict,_=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=D.POST,n.path=O,n.params=r({user_ids:v([s],m(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:d,is_public:h,is_discoverable:p,strict:f,is_ephemeral:_,access_code:g,name:y,data:C,custom_type:E,operator_ids:N,message_survival_seconds:b}),n}return e(n,t),n}(F),Tn=function(t){function n(e,n){var r,s=this;return(s=t.call(this,e,n)||this).channel=new cs(e,n),s.isCreated=null===(r=n.is_created)||void 0===r||r,s}return e(n,t),n}(R),An=function(t){function n(e){var n=e.userId,r=e.channelUrls,s=t.call(this)||this;return s.method=D.PUT,s.path="".concat(k,"/").concat(encodeURIComponent(n),"/mark_as_read_all"),s.params={channel_urls:r},s}return e(n,t),n}(F);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(R);var In=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.accessCode;return(n=t.call(this)||this).method=D.PUT,n.path="".concat(O,"/").concat(encodeURIComponent(r),"/join"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(F),wn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new cs(e,n),r}return e(n,t),n}(R),Ln=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,a=i.member_count,o=void 0===a?0:a,u=i.joined_member_count,c=void 0===u?0: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 zt(e,t)})):[new zt(e,r.data)],s}return e(n,t),n}(ct),Dn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.shouldRemoveOperatorStatus;return(n=t.call(this)||this).method=D.PUT,n.path="".concat(O,"/").concat(encodeURIComponent(r),"/leave"),n.params={user_id:s,should_remove_operator_status:i},n}return e(n,t),n}(F);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(R);var kn=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,a=i.member_count,o=void 0===a?0:a,u=i.joined_member_count,c=void 0===u?0:u;return s.memberCount=o,s.joinedMemberCount=c,s.member=new zt(s._iid,r.data),s}return e(n,t),n}(ct),Pn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userIds;return(n=t.call(this)||this).method=D.POST,n.path="".concat(O,"/").concat(encodeURIComponent(r),"/invite"),n.params={user_ids:s},n}return e(n,t),n}(F),Fn=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new cs(e,n),r}return e(n,t),n}(R),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?0:a,u=i.joined_member_count,l=void 0===u?0:u,h=i.inviter,d=i.invitees,p=void 0===d?[]:d;return s.memberCount=o,s.joinedMemberCount=l,s.inviter=new c(e,h),s.invitees=p.map((function(t){return new zt(e,t)})),s}return e(n,t),n}(ct),xn=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId;return(n=t.call(this)||this).method=D.PUT,n.path="".concat(O,"/").concat(encodeURIComponent(r),"/decline"),n.params={user_id:s},n}return e(n,t),n}(F);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new cs(e,n),r.channel.myMemberState=Rt.NONE,r}e(n,t)}(R);var On=function(t){function n(e,n,r){var s=t.call(this,e,n,r)||this,i=r.data,a=i.member_count,o=i.joined_member_count,u=i.inviter,l=i.invitee;return s.memberCount=null!=a?a:0,s.joinedMemberCount=null!=o?o:0,s.inviter=new c(e,u),s.invitee=new zt(e,l),s}return e(n,t),n}(ct),Hn=function(t){function n(e){var n=e.channelUrl;return t.call(this,{code:"READ",ackRequired:!0,payload:{channel_url:n}})||this}return e(n,t),n}(V),Gn=function(t){function n(e,n,r){var s=t.call(this,e,"READ",r)||this;return s.readStatus=new jt(e,r),s}return e(n,t),n}(q),Vn=function(t){function n(e){var n=e.channelUrl,s=e.userId,i=t.call(this)||this;return(i=t.call(this)||this).method=D.PUT,i.path="".concat(O,"/").concat(encodeURIComponent(n),"/messages/mark_as_delivered"),i.params=r({userId:s}),i}return e(n,t),n}(F);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(R);var qn,Bn=function(t){function n(e,n,r){var s=t.call(this,e,"DLVR",r)||this;return s.channelUrl=r.channel_url,s.deliveredStateUpdate=r.updated,s}return e(n,t),n}(q),Wn={hidePreviousMessages:!1,allowAutoUnhide:!0},zn=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=D.PUT,n.path="".concat(O,"/").concat(encodeURIComponent(r),"/hide"),n.params={user_id:s,hide_previous_messages:null!=i?i:Wn.hidePreviousMessages,allow_auto_unhide:null!=a?a:Wn.allowAutoUnhide},n}return e(n,t),n}(F),jn=function(t){function n(e,n){var r=t.call(this,e,n)||this,s=n.ts_message_offset;return r.messageOffsetTimestamp=s,r}return e(n,t),n}(R),Qn=function(t){function n(e,n,r){var s,i,a,o=this;return(o=t.call(this,e,"SYEV",r)||this).allowAutoUnhide=null,o.hidePreviousMessages=null,o.messageOffsetTimestamp=null,r.data&&(o.allowAutoUnhide=null!==(s=r.data.allow_auto_unhide)&&void 0!==s?s:null,o.hidePreviousMessages=null!==(i=r.data.hide_previous_messages)&&void 0!==i?i:null),o.messageOffsetTimestamp=null!==(a=r.ts_message_offset)&&void 0!==a?a:null,o}return e(n,t),n}(q),Kn=function(t){function n(e){var n=e.channelUrl,r=e.time;return t.call(this,{code:"TPST",ackRequired:!1,payload:{channel_url:n,time:r}})||this}return e(n,t),n}(V),Yn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.user=new c(e,r.data),s}return e(n,t),n}(q),Jn=function(t){function n(e){var n=e.channelUrl,r=e.time;return t.call(this,{code:"TPEN",ackRequired:!1,payload:{channel_url:n,time:r}})||this}return e(n,t),n}(V),Xn=function(t){function n(e,n,r){var s=t.call(this,e,"SYEV",r)||this;return s.user=new c(e,r.data),s}return e(n,t),n}(q),Zn=function(t){function n(e){var n=e.channelUrl,r=e.messageId;return t.call(this,{code:"MACK",ackRequired:!1,payload:{channel_url:n,msg_id:r}})||this}return e(n,t),n}(V),$n=function(t){function n(e,n){var r,s,i,a,o,u,c,l,h,d,p,f,_,v,m,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=Ot.ALL,S.unreadChannelFilter=Gt.ALL,S.superChannelFilter=Ht.ALL,S.publicChannelFilter=xt.ALL,S.hiddenChannelFilter=Vt.UNHIDDEN,S.searchFilter={fields:[],query:null},S.userIdsFilter={userIds:[],includeMode:!0,queryType:Bt.AND},S.metadataKey=null,S.metadataValues=null,S.metadataOrderKeyFilter=null,S.metadataValueStartsWith=null,S.order=Ge.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:Ot.ALL,S.unreadChannelFilter=null!==(f=n.unreadChannelFilter)&&void 0!==f?f:Gt.ALL,S.superChannelFilter=null!==(_=n.superChannelFilter)&&void 0!==_?_:Ht.ALL,S.publicChannelFilter=null!==(v=n.publicChannelFilter)&&void 0!==v?v:xt.ALL,S.hiddenChannelFilter=null!==(m=n.hiddenChannelFilter)&&void 0!==m?m:Vt.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:Bt.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:Ge.LATEST_LAST_MESSAGE,S}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&b("boolean",this.includeEmpty)&&b("boolean",this.includeFrozen)&&b("boolean",this.includeMetaData)&&b("string",this.channelNameContainsFilter)&&E("string",this.channelUrlsFilter,!0)&&E("string",this.customTypesFilter,!0)&&b("string",this.customTypeStartsWithFilter)&&b("string",this.nicknameContainsFilter,!0)&&b("string",this.nicknameStartsWithFilter,!0)&&b("string",this.nicknameExactMatchFilter,!0)&&a(Ot,this.myMemberStateFilter)&&a(Ht,this.superChannelFilter)&&a(xt,this.publicChannelFilter)&&a(Gt,this.unreadChannelFilter)&&a(Vt,this.hiddenChannelFilter)&&E(Wt,this.searchFilter.fields)&&b("string",this.searchFilter.query,!0)&&E("string",this.userIdsFilter.userIds)&&b("boolean",this.userIdsFilter.includeMode)&&a(Bt,this.userIdsFilter.queryType)&&a(Ge,this.order)&&b("string",this.metadataOrderKeyFilter,!0)&&b("string",this.metadataKey,!0)&&E("string",this.metadataValues,!0)&&b("string",this.metadataValueStartsWith,!0)},n.prototype.serialize=function(){return B(this)},n.prototype.next=function(){return g(this,void 0,void 0,(function(){var e,t,n;return y(this,(function(r){switch(r.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,[4,rr.of(this._iid).getMyGroupChannels(this._token,s(i({},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 _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},n}(W),er=function(){function e(e){var t=e.top,n=void 0===t?Number.MAX_SAFE_INTEGER:t,r=e.bottom,s=void 0===r?0:r;this.top=n,this.bottom=s}return e.prototype.includes=function(){for(var e=this,t=[],n=0;n0||D.unreadMentionCount>0)&&(D._updateUnreadCount(0,0),this._dispatcher.dispatch(new We({channels:[D],source:ze.EVENT_CHANNEL_READ})),Y((function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(D)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))):0!==D.unreadMessageCount&&0!==D.unreadMentionCount||(this._dispatcher.dispatch(new We({channels:[D],source:ze.EVENT_CHANNEL_READ})),Y((function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(D)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))):(this._dispatcher.dispatch(new We({channels:[D],source:ze.EVENT_CHANNEL_READ})),Y((function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onUnreadMemberStatusUpdated&&n.onUnreadMemberStatusUpdated(D)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))),Sn.label=12;case 12:return[3,79];case 13:return k=e.as(Bn),le=k.channelUrl,P=k.deliveredStateUpdate,F=void 0===P?{}:P,R=this._groupChannelCache.isCachedInMemory(le),[4,this.getChannel(le,!0)];case 14:if(x=Sn.sent(),R)for(O in F)x._updateUndeliveredMemberState(O,F[O]);return Object.keys(F).some((function(e){return e!==Nn._sdkState.userId}))&&(this._dispatcher.dispatch(new We({channels:[x],source:ze.EVENT_CHANNEL_DELIVERED})),Y((function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onUndeliveredMemberStatusUpdated&&n.onUndeliveredMemberStatusUpdated(x)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))),[3,79];case 15:return H=e.as(_t),le=H.channelUrl,he=H.channelType,G=H.event,he!==u.GROUP?[3,18]:[4,this.getChannel(le,!0)];case 16:return V=Sn.sent(),[4,this.getMessageFromCache(G.messageId)];case 17:(W=Sn.sent())&&(W.applyReactionEvent(G),this._dispatcher.dispatch(new L({messages:[W],source:J.EVENT_MESSAGE_REACTION_UPDATED}))),Y((function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onReactionUpdated&&n.onReactionUpdated(V,G)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))})),Sn.label=18;case 18:return[3,79];case 19:return(q=e.as(ft).event).channelType!==u.GROUP?[3,22]:[4,this.getChannel(q.channelUrl,!0)];case 20:return B=Sn.sent(),[4,this.getMessageFromCache(q.targetMessageId)];case 21:(W=Sn.sent())&&(W.applyThreadInfoUpdateEvent(q),this._dispatcher.dispatch(new L({messages:[W],source:J.EVENT_MESSAGE_THREADINFO_UPDATED}))),Y((function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onThreadInfoUpdated&&n.onThreadInfoUpdated(B,q)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))})),Sn.label=22;case 22:return[3,79];case 23:z=e.as(pt).groupChannelMemberCounts,Q=[],Sn.label=24;case 24:Sn.trys.push([24,29,30,31]),X=C(z),$=X.next(),Sn.label=25;case 25:return $.done?[3,28]:(ee=$.value,le=ee.channelUrl,it=ee.memberCount,at=ee.joinedMemberCount,te=ee.updatedAt,[4,this.getChannelFromCache(le)]);case 26:(ne=Sn.sent())&&ne._setLatestMemberCount(it,at,te)&&Q.push(ne),Sn.label=27;case 27:return $=X.next(),[3,25];case 28:return[3,31];case 29:return re=Sn.sent(),vn={error:re},[3,31];case 30:try{$&&!$.done&&(mn=X.return)&&mn.call(X)}finally{if(vn)throw vn.error}return[7];case 31:return Q.length>0&&(this._dispatcher.dispatch(new We({channels:Q,source:ze.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),Y((function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelMemberCountChanged&&n.onChannelMemberCountChanged(Q)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))}))),[3,79];case 32:return se=e.as(dt),ie=se.event,ae=se.status,le=se.channelUrl,he=se.channelType,le&&he===u.GROUP?[4,this.getChannel(le,!0)]:[3,34];case 33:oe=Sn.sent(),this._dispatcher.dispatch(new T({event:ie,source:J.EVENT_POLL_UPDATED})),Y(ae===Z?function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollDeleted&&n.onPollDeleted(oe,ie.pollId)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))}:function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollUpdated&&n.onPollUpdated(oe,ie)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))}),Sn.label=34;case 34:return[3,79];case 35:return ue=e.as(Te),ce=ue.event,le=ue.channelUrl,he=ue.channelType,le&&he===u.GROUP?[4,this.getChannel(le,!0)]:[3,37];case 36:de=Sn.sent(),this._dispatcher.dispatch(new U({event:ce,source:J.EVENT_POLL_VOTED})),Y((function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onPollVoted&&n.onPollVoted(de,ce)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))})),Sn.label=37;case 37:return[3,79];case 38:if(!(pe=e.as(ct).event).isGroupChannelEvent)return[3,77];switch(pe.category){case lt.CHANNEL_JOIN:return[3,39];case lt.CHANNEL_LEAVE:return[3,41];case lt.CHANNEL_OPERATOR_UPDATE:return[3,45];case lt.CHANNEL_INVITE:return[3,47];case lt.CHANNEL_DECLINE_INVITE:return[3,49];case lt.TYPING_START:case lt.TYPING_END:return[3,51];case lt.USER_CHANNEL_MUTE:case lt.USER_CHANNEL_UNMUTE:return[3,53];case lt.USER_CHANNEL_BAN:return[3,55];case lt.USER_CHANNEL_UNBAN:return[3,59];case lt.CHANNEL_FREEZE:case lt.CHANNEL_UNFREEZE:return[3,61];case lt.CHANNEL_HIDE:return[3,63];case lt.CHANNEL_UNHIDE:return[3,65];case lt.CHANNEL_DELETED:return[3,67];case lt.CHANNEL_PROP_CHANGED:return[3,69];case lt.CHANNEL_META_DATA_CHANGED:return[3,71];case lt.CHANNEL_META_COUNTERS_CHANGED:return[3,73];case lt.PINNED_MESSAGE_CHANGED:return[3,75]}return[3,77];case 39:return[4,this.getChannel(pe.channelUrl,!0)];case 40:return fe=Sn.sent(),_e=e.as(Ln),ve=_e.memberCount,me=_e.joinedMemberCount,ge=_e.members,ye=!1,ge.forEach((function(e){fe.isExclusive||fe.isSuper||fe.isBroadcast?ye=ye||fe._setLatestMemberCount(ve,me,pe.ts):(e.state=Rt.JOINED,fe.addMember(e,pe.ts),Nn._updateJoinedMemberCount(fe)),e.userId===Nn._sdkState.userId&&(fe.myMemberState=Rt.JOINED)})),this._dispatcher.dispatch(new We({channels:[fe],source:ze.EVENT_CHANNEL_JOINED})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){var t,n;try{for(var r=C(ge),s=r.next();!s.done;s=r.next()){var i=s.value;e.onUserJoined&&e.onUserJoined(fe,i)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}fe.isBroadcast&&ye&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([fe])})),[2]}))}))})),[3,77];case 41:return(It=this._leftChannels.get(pe.channelUrl))?(ke=It.channel,[3,44]):[3,42];case 42:return[4,this.getChannel(pe.channelUrl,!0)];case 43:ke=Sn.sent(),Sn.label=44;case 44:return De=ke,Pe=e.as(kn),it=Pe.memberCount,at=Pe.joinedMemberCount,Fe=Pe.member,Re=!1,xe=j.of(this._iid).appInfo,De.isExclusive||De.isSuper||De.isBroadcast?Re=De._setLatestMemberCount(it,at,pe.ts):((null==xe?void 0:xe.enabledChannelMemberShipHistory)?((Oe=De.members.find((function(e){return e.userId===Oe.userId})))&&(Oe.state=Rt.LEFT),De.memberCount=it):De.removeMember(Fe),this._updateJoinedMemberCount(De)),Fe.userId===this._sdkState.userId?(De.myMemberState=Rt.NONE,De.invitedAt=0,De.joinedAt=0,De._updateUnreadCount(0,0),De.isPublic?this._dispatcher.dispatch(new We({channels:[De],source:ze.EVENT_CHANNEL_LEFT})):(this._markAsLeave(De),this._dispatcher.dispatch(new Be({channelUrls:[De.url],source:ze.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new We({channels:[De],source:ze.EVENT_CHANNEL_LEFT})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserLeft&&e.onUserLeft(De,Fe),De.isBroadcast&&Re&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([De])})),[2]}))}))})),[3,77];case 45:return[4,this.getChannel(pe.channelUrl,!0)];case 46:He=Sn.sent(),Ge=e.as(ht).operators,Ve=Ge.map((function(e){return e.userId}));try{for(qe=C(He.members),je=qe.next();!je.done;je=qe.next())(At=je.value).role=Ve.includes(At.userId)?o.OPERATOR:o.NONE}catch(e){gn={error:e}}finally{try{je&&!je.done&&(yn=qe.return)&&yn.call(qe)}finally{if(gn)throw gn.error}}return He.myRole=Ve.includes(this._sdkState.userId)?o.OPERATOR:o.NONE,this._dispatcher.dispatch(new We({channels:[He],source:ze.EVENT_CHANNEL_OPERATOR_UPDATED})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onOperatorUpdated&&e.onOperatorUpdated(He,Ge)})),[2]}))}))})),[3,77];case 47:return[4,this.getChannel(pe.channelUrl,!0)];case 48:Qe=Sn.sent(),Ke=e.as(Rn),it=Ke.memberCount,at=Ke.joinedMemberCount,Ye=Ke.inviter,(Je=Ke.invitees).forEach((function(e){return e.state=Rt.INVITED}));try{for(Xe=C(Je),tt=Xe.next();!tt.done;tt=Xe.next())nt=tt.value,Qe.isExclusive||Qe.isSuper||Qe.isBroadcast?Qe._setLatestMemberCount(it,at,pe.ts):Qe.addMember(nt,pe.ts),this._sdkState.userId===nt.userId&&(Qe.hiddenState=rs.UNHIDDEN,Qe.myMemberState!==Rt.JOINED&&(Qe.myMemberState=Rt.INVITED),Qe.invitedAt=pe.ts)}catch(e){Cn={error:e}}finally{try{tt&&!tt.done&&(En=Xe.return)&&En.call(Xe)}finally{if(Cn)throw Cn.error}}return this._dispatcher.dispatch(new We({channels:[Qe],source:ze.EVENT_CHANNEL_INVITED})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserReceivedInvitation&&e.onUserReceivedInvitation(Qe,Ye,Je)})),[2]}))}))})),[3,77];case 49:return[4,this.getChannel(pe.channelUrl,!0)];case 50:return rt=Sn.sent(),st=e.as(On),it=st.memberCount,at=st.joinedMemberCount,ot=st.inviter,ut=st.invitee,rt.isExclusive||rt.isSuper||rt.isBroadcast?rt._setLatestMemberCount(it,at,pe.ts):rt.removeMember(ut),this._sdkState.userId===ut.userId?(rt.invitedAt=0,rt.myMemberState=Rt.NONE,rt.isPublic?this._dispatcher.dispatch(new We({channels:[rt],source:ze.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new Be({channelUrls:[rt.url],source:ze.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new We({channels:[rt],source:ze.EVENT_CHANNEL_DECLINED_INVITE})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserDeclinedInvitation&&e.onUserDeclinedInvitation(rt,ot,ut)})),[2]}))}))})),[3,77];case 51:return[4,this.getChannel(pe.channelUrl,!0)];case 52:return gt=Sn.sent(),yt=pe.category===lt.TYPING_START,Et=e.as(yt?Yn:Xn).user,gt._updateTypingStatus(Et,yt?pe.ts:0),this._dispatcher.dispatch(new We({channels:[gt],source:ze.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onTypingStatusUpdated&&e.onTypingStatusUpdated(gt)})),[2]}))}))})),[3,77];case 53:return[4,this.getChannel(pe.channelUrl,!0)];case 54:bt=Sn.sent(),Mt=pe.category===lt.USER_CHANNEL_MUTE,(Nt=e.as(Mt?Se:Ue).user).userId===this._sdkState.userId&&(bt.myMutedState=Mt?ns.MUTED:ns.UNMUTED,bt._myMutedRemainingTime=Nt.restrictionInfo.remainingDuration);try{for(Ut=C(bt.members),Tt=Ut.next();!Tt.done;Tt=Ut.next())if((At=Tt.value).userId===Nt.userId){At.isMuted=Mt;break}}catch(e){bn={error:e}}finally{try{Tt&&!Tt.done&&(Mn=Ut.return)&&Mn.call(Ut)}finally{if(bn)throw bn.error}}return this._dispatcher.dispatch(new We({channels:[bt],source:Mt?ze.EVENT_CHANNEL_MUTED:ze.EVENT_CHANNEL_UNMUTED,data:Nt.userId})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Mt?e.onUserMuted&&e.onUserMuted(bt,Nt):e.onUserUnmuted&&e.onUserUnmuted(bt,Nt)})),[2]}))}))})),[3,77];case 55:return(It=this._leftChannels.get(pe.channelUrl))?(Lt=It.channel,[3,58]):[3,56];case 56:return[4,this.getChannel(pe.channelUrl,!0)];case 57:Lt=Sn.sent(),Sn.label=58;case 58:return wt=Lt,this._markAsLeave(wt),Dt=e.as(Ne).user,Dt.userId===this._sdkState.userId&&this._dispatcher.dispatch(new Be({channelUrls:[wt.url],source:ze.EVENT_CHANNEL_BANNED})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserBanned&&e.onUserBanned(wt,Dt)})),[2]}))}))})),[3,77];case 59:return[4,this.getChannel(pe.channelUrl,!0)];case 60:return kt=Sn.sent(),Pt=e.as(Me).user,Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onUserUnbanned&&e.onUserUnbanned(kt,Pt)})),[2]}))}))})),[3,77];case 61:return[4,this.getChannel(pe.channelUrl,!0)];case 62:return Ft=Sn.sent(),xt=e.as(be).freeze,Ft.isFrozen=xt,this._dispatcher.dispatch(new We({channels:[Ft],source:xt?ze.EVENT_CHANNEL_FROZEN:ze.EVENT_CHANNEL_UNFROZEN})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){xt?e.onChannelFrozen&&e.onChannelFrozen(Ft):e.onChannelUnfrozen&&e.onChannelUnfrozen(Ft)})),[2]}))}))})),[3,77];case 63:return[4,this.getChannel(pe.channelUrl,!0)];case 64:return Ot=Sn.sent(),Ht=e.as(Qn),Gt=Ht.allowAutoUnhide,Vt=Ht.hidePreviousMessages,qt=Ht.messageOffsetTimestamp,null!==Gt&&(Ot.hiddenState=Gt?rs.HIDDEN_ALLOW_AUTO_UNHIDE:rs.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Vt&&Vt&&Ot._updateUnreadCount(0,0),null!==qt&&(Ot.messageOffsetTimestamp=qt),this._dispatcher.dispatch(new We({channels:[Ot],source:ze.EVENT_CHANNEL_HIDDEN})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelHidden&&e.onChannelHidden(Ot)})),[2]}))}))})),[3,77];case 65:return[4,this.getChannel(pe.channelUrl,!0)];case 66:return(Bt=Sn.sent()).hiddenState=rs.UNHIDDEN,this._dispatcher.dispatch(new We({channels:[Bt],source:ze.EVENT_CHANNEL_UNHIDDEN})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Bt)})),[2]}))}))})),[3,77];case 67:return[4,this.getChannel(pe.channelUrl,!0)];case 68:return Wt=Sn.sent(),this._dispatcher.dispatch(new Be({channelUrls:[pe.channelUrl],source:ze.EVENT_CHANNEL_DELETED})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Wt.url,Wt.channelType)})),[2]}))}))})),[3,77];case 69:return[4,this.getChannelWithoutCache(pe.channelUrl,!0)];case 70:return zt=Sn.sent(),this._dispatcher.dispatch(new We({channels:[zt],source:ze.EVENT_CHANNEL_UPDATED})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(zt)})),[2]}))}))})),[3,77];case 71:return[4,this.getChannel(pe.channelUrl,!0)];case 72:return jt=Sn.sent(),Qt=e.as(Ee),Kt=Qt.created,Yt=Qt.updated,Jt=Qt.deleted,Kt&&jt._upsertCachedMetaData(Kt,pe.ts),Yt&&jt._upsertCachedMetaData(Yt,pe.ts),Jt&&jt._removeFromCachedMetaData(Jt,pe.ts),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){Kt&&e.onMetaDataCreated&&e.onMetaDataCreated(jt,Kt),Yt&&e.onMetaDataUpdated&&e.onMetaDataUpdated(jt,Yt),Jt&&e.onMetaDataDeleted&&e.onMetaDataDeleted(jt,Jt)})),[2]}))}))})),[3,77];case 73:return[4,this.getChannel(pe.channelUrl,!0)];case 74:return Xt=Sn.sent(),Zt=e.as(Ce),$t=Zt.created,en=Zt.updated,tn=Zt.deleted,Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){$t&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Xt,$t),en&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Xt,en),tn&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Xt,tn)})),[2]}))}))})),[3,77];case 75:return[4,this.getChannel(pe.channelUrl,!0)];case 76:return nn=Sn.sent(),rn=e.as(tr),sn=rn.pinnedMessageIds,an=rn.latestPinnedMessage,(on=rn.ts)>nn._pinnedMessagesUpdatedAt&&(nn.pinnedMessageIds=sn,nn.lastPinnedMessage=an,nn._pinnedMessagesUpdatedAt=on,this._dispatcher.dispatch(new We({channels:[nn],source:ze.EVENT_PINNED_MESSAGE_UPDATED})),Y((function(){return g(Nn,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){try{for(e=C(this._groupChannelHandlers.values()),t=e.next();!t.done;t=e.next())(n=t.value).onChannelChanged&&n.onChannelChanged(nn)}catch(e){r={error:e}}finally{try{t&&!t.done&&(s=e.return)&&s.call(e)}finally{if(r)throw r.error}}return[2]}))}))})),Y((function(){return g(Nn,void 0,void 0,(function(){return y(this,(function(e){return this._groupChannelHandlers.forEach((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(nn)})),[2]}))}))}))),[3,77];case 77:return[3,79];case 78:switch((un=e.as(Ze).event).category){case $e.USER_BLOCK:cn=et.getDataAsUserBlockEvent(this._iid,un),hn=cn.blocker,dn=cn.blockee,this._groupChannelCache.block(hn.userId,dn.userId);break;case $e.USER_UNBLOCK:ln=et.getDataAsUserBlockEvent(this._iid,un),hn=ln.blocker,dn=ln.blockee,this._groupChannelCache.unblock(hn.userId,dn.userId)}return[3,79];case 79:return[3,81];case 80:if(pn=Sn.sent(),K(pn))throw pn;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===Rt.JOINED})).length},e.prototype.getChannel=function(e,t){return void 0===t&&(t=!1),g(this,void 0,void 0,(function(){var n;return y(this,(function(r){switch(r.label){case 0:f(b("string",e)).throw(_.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),g(this,void 0,void 0,(function(){var n,r,s,i,a;return y(this,(function(o){switch(o.label){case 0:return f(b("string",e)).throw(_.invalidParameters),n=new ln({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(n)];case 1:switch(r=o.sent(),s=r.as(hn).channel,i=s.unreadMessageCount,a=s.unreadMentionCount,s.myCountPreference){case ts.UNREAD_MESSAGE_COUNT_ONLY:a=0;break;case ts.UNREAD_MENTION_COUNT_ONLY:i=0;break;case ts.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=ze.REFRESH_CHANNEL),g(this,void 0,void 0,(function(){var r,s,i,a,o;return y(this,(function(u){switch(u.label){case 0:return u.trys.push([0,5,,6]),r=new ln({channelUrl:e,isInternalCall:t}),[4,this._requestQueue.send(r)];case 1:return s=u.sent(),(i=s.as(hn).channel).myMemberState!==Rt.NONE?[3,2]:(this._dispatcher.dispatch(new Be({channelUrls:[i.url],source:n})),[3,4]);case 2:return[4,this.upsertChannelsToCache([i])];case 3:a=u.sent(),this._dispatcher.dispatch(new We({channels:a,source:n})),u.label=4;case 4:return[3,6];case 5:return(o=u.sent()).code!==X.NON_AUTHORIZED&&o.code!==X.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new Be({channelUrls:[e],source:n})),[3,6];case 6:return[2]}}))}))},e.prototype.getMyGroupChannels=function(e,t,n,r){return void 0===r&&(r=ze.REQUEST_CHANNEL),g(this,void 0,void 0,(function(){var s,a,o,u,c;return y(this,(function(l){switch(l.label){case 0:return s=new pn(i(i({},t),{userId:this._sdkState.userId,token:e,limit:n})),[4,this._requestQueue.send(s)];case 1:return a=l.sent(),o=a.as(fn),u=o.channels,c=o.token,this._dispatcher.dispatch(new We({channels:u,source:r})),[2,{channels:u,token:c}]}}))}))},e.prototype.getMessageFromCache=function(e){var t;return g(this,void 0,void 0,(function(){return y(this,(function(n){switch(n.label){case 0:return[4,this._messageCache.get(e)];case 1:return[2,null!==(t=n.sent())&&void 0!==t?t:null]}}))}))},e.prototype._getExactlyMatchingMessagesForTokenFromCache=function(e,t,n){return g(this,void 0,void 0,(function(){return y(this,(function(r){switch(r.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,filter:n,exactMatch:!0})];case 1:return[2,r.sent()]}}))}))},e.prototype.getMessagesFromCache=function(e,t,n,r,s,i){return void 0===s&&(s=De),void 0===i&&(i=!0),g(this,void 0,void 0,(function(){return y(this,(function(a){switch(a.label){case 0:return[4,this._messageCache.fetch({channelUrl:e,token:t,limit:s,filter:r,backward:"next"===n,inclusive:i})];case 1:return[2,a.sent()]}}))}))},e.prototype.getPollMessagesFromCache=function(e,t,n,r){return void 0===r&&(r=De),g(this,void 0,void 0,(function(){return y(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 g(this,void 0,void 0,(function(){return y(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 g(this,void 0,void 0,(function(){return y(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 g(this,void 0,void 0,(function(){return y(this,(function(s){switch(s.label){case 0:return[4,this._messageCache.countBetween(e,t,new er({top:n,bottom:r}))];case 1:return[2,s.sent()]}}))}))},e.prototype.getMyGroupChannelChangeLogs=function(e,t,n){return void 0===n&&(n=ze.REQUEST_CHANNEL_CHANGELOGS),g(this,void 0,void 0,(function(){var r,a,o,u,c,l,h;return y(this,(function(d){switch(d.label){case 0:return r=i(i({},Zt),t),f((b("string",e)||b("number",e))&&$t(r)).throw(_.invalidParameters),a=new un(s({userId:this._sdkState.userId,ts:"number"==typeof e?e:null,token:"string"==typeof e?e:null,filter:r})),[4,this._requestQueue.send(a)];case 1:return o=d.sent(),u=o.as(cn),c=u.updatedChannels,l=u.deletedChannelUrls,h=u.hasMore,c.length>0&&this._dispatcher.dispatch(new We({channels:c,source:n})),l.length>0&&this._dispatcher.dispatch(new Be({channelUrls:l,source:n})),[2,{updatedChannels:c,deletedChannelUrls:l,hasMore:h,token:u.token}]}}))}))},e.prototype.getGroupChannelCount=function(e){return g(this,void 0,void 0,(function(){var t,n,r;return y(this,(function(s){switch(s.label){case 0:return t=i(i({},en),e),f(tn(t)).throw(_.invalidParameters),n=new _n({userId:this._sdkState.userId,filter:t}),[4,this._requestQueue.send(n)];case 1:return r=s.sent(),[2,r.as(vn).groupChannelCount]}}))}))},e.prototype.getUnreadItemCount=function(e){return g(this,void 0,void 0,(function(){var t,n,s,a,o,u,c,l,h,d,p,v,m,g,C,b;return y(this,(function(y){switch(y.label){case 0:return t=i(i({},nn),e),f(function(e){return E(Qt,e.keys)}(t)).throw(_.invalidParameters),n=j.of(this._iid),s=n.sdkState,a=n.requestQueue,o=new mn({userId:s.userId,filter:t}),[4,a.send(o)];case 1:return u=y.sent(),c=u.as(gn),l=c.groupChannelUnreadMentionCount,h=c.groupChannelUnreadMessageCount,d=c.groupChannelInvitationCount,p=c.superGroupChannelUnreadMentionCount,v=c.superGroupChannelUnreadMessageCount,m=c.superGroupChannelInvitationCount,g=c.nonSuperGroupChannelUnreadMentionCount,C=c.nonSuperGroupChannelUnreadMessageCount,b=c.nonSuperGroupChannelInvitationCount,[2,r({groupChannelUnreadMentionCount:l,groupChannelUnreadMessageCount:h,groupChannelInvitationCount:d,superGroupChannelUnreadMentionCount:p,superGroupChannelUnreadMessageCount:v,superGroupChannelInvitationCount:m,nonSuperGroupChannelUnreadMentionCount:g,nonSuperGroupChannelUnreadMessageCount:C,nonSuperGroupChannelInvitationCount:b})]}}))}))},e.prototype.getTotalUnreadChannelCount=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,s;return y(this,(function(i){switch(i.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new yn({userId:t.userId}),[4,n.send(r)];case 1:return s=i.sent(),[2,s.as(Cn).unreadCount]}}))}))},e.prototype.getTotalUnreadMessageCount=function(e){return g(this,void 0,void 0,(function(){var t,n,r,s,o,u;return y(this,(function(c){switch(c.label){case 0:return t=i(i({},rn),e),f(function(e){return E("string",e.channelCustomTypesFilter,!0)&&a(Ht,e.superChannelFilter)}(t)).throw(_.invalidParameters),n=j.of(this._iid),r=n.sdkState,s=n.requestQueue,o=new En({userId:r.userId,filter:t}),[4,s.send(o)];case 1:return u=c.sent(),[2,u.as(bn).unreadCount]}}))}))},e.prototype.getTotalScheduledMessageCount=function(e){return void 0===e&&(e={}),g(this,void 0,void 0,(function(){var t,n,r,s;return y(this,(function(o){switch(o.label){case 0:return t=i(i({},sn),e),f(function(e){return b("string",e.channelUrl,!0)&&E(yt,e.scheduledStatus,!0)&&a(N,e.messageTypeFilter)}(t)).throw(_.invalidParameters),n=j.of(this._iid).requestQueue,r=new Mn(t),[4,n.send(r)];case 1:return s=o.sent(),[2,s.as(Nn).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 g(this,void 0,void 0,(function(){var t,n,r,s;return y(this,(function(a){switch(a.label){case 0:return t=i(i({},Jt),e),f(Xt(t)).throw(_.invalidParameters),t.isPublic||(t.accessCode=void 0),n=new Un(i({userId:this._sdkState.userId},t)),[4,this._requestQueue.send(n)];case 1:return r=a.sent(),s=r.as(Tn).channel,[4,this.upsertChannelsToCache([s])];case 2:return a.sent(),[2,s]}}))}))},e.prototype.markAsReadAll=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,o;return y(this,(function(u){switch(u.label){case 0:return e=Date.now(),f(e-this._markAsReadAllLastSentAt>=1e3).throw(_.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=e,t=new An({userId:this._sdkState.userId}),[4,this._requestQueue.send(t)];case 1:u.sent(),n=this._groupChannelCache.channels;try{for(r=C(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 g(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,c;return y(this,(function(l){switch(l.label){case 0:return t=Date.now(),f(E("string",e)&&t-this._markAsReadAllLastSentAt>=1e3).throw(_.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=t,n=new An({userId:this._sdkState.userId,channelUrls:e}),[4,this._requestQueue.send(n)];case 1:l.sent(),r=this._groupChannelCache.channels,s=[];try{for(i=C(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 g(this,void 0,void 0,(function(){return y(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"}(qn||(qn={}));var sr,ir=function(t){function n(e,n,r,s){var i=t.call(this)||this;return i._state=qn.IDLE,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===qn.IDLE},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isRunning",{get:function(){return this._state===qn.RUNNING},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isDone",{get:function(){return this._state===qn.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 g(this,void 0,void 0,(function(){var t,n;return y(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})),(null===(l=this._metadata)||void 0===l?void 0:(i=l.range).intersect.apply(i,v([],m(r),!1)))?this.extendRange(n):this._metadata={range:new er({top:Math.min.apply(Math,v([],m(r),!1)),bottom:Math.max.apply(Math,v([],m(r),!1))}),previousComplete:!1}),t.hasNext=n.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(t.nextToken=this._metadata.range.top,this._metadata.previousComplete=n.length0&&(r=n.map((function(e){return e.createdAt})),(null===(c=this._metadata)||void 0===c?void 0:(i=c.range).intersect.apply(i,v([],m(r),!1)))?this.extendRange(n):this._metadata={range:new er({top:Math.min.apply(Math,v([],m(r),!1)),bottom:Math.max.apply(Math,v([],m(r),!1))}),previousComplete:!1}),t.hasNext=n.length>=this._limit&&this._nextSyncLoopCount<1,this._metadata&&(t.nextToken=this._metadata.range.bottom),h.debug("message background next sync progress",t),[4,this.saveMetadata()];case 4:return l.sent(),[3,6];case 5:throw s=l.sent(),h.debug("message background next sync error",s),s;case 6:return[2,t]}}))}))})),this._connectionEventContext=l.on((function(e){if(e instanceof ee)if(e.stateType===te.CONNECTED)i.resume();else i.pause()}))}return e.of=function(t,n){return ur[t]||(ur[t]={}),ur[t][n.url]||(ur[t][n.url]=new e({_iid:t,channel:n})),ur[t][n.url].ref++,ur[t][n.url]},e.clear=function(e,t){ur[e]&&ur[e][t]&&(ur[e][t].close(),delete ur[e])},Object.defineProperty(e.prototype,"range",{get:function(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new er({})},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,v([],m(e.map((function(e){return e.createdAt}))),!1))},e.prototype.extendRange=function(e){var t;this._metadata&&(t=this._metadata.range).extends.apply(t,v([],m(e.map((function(e){return e.createdAt}))),!1))},e.prototype.loadMetadata=function(e){return g(this,void 0,void 0,(function(){var t;return y(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&&(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 _&&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 ee)if(e.stateType===te.CONNECTED)r.resume();else r.pause()}))}return e.of=function(t,n){return lr[t]||(lr[t]={}),lr[t][n.url]||(lr[t][n.url]=new e({_iid:t,channel:n})),lr[t][n.url].ref++,lr[t][n.url]},e.clear=function(e,t){lr[e]&&lr[e][t]&&(lr[e][t].close(),delete lr[e])},e.prototype.loadMetadata=function(){return g(this,void 0,void 0,(function(){var e,t,n,r;return y(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 g(this,void 0,void 0,(function(){return y(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 g(this,void 0,void 0,(function(){return y(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=void 0,[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,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 lr[this._iid][this._channel.url])},e}(),dr={},pr=function(){function e(e){var t=e._iid,n=e.channel,r=e.hasPollMessage,s=this;this.ref=0,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 ir(h,(function(){return g(s,void 0,void 0,(function(){var e,t,n,s,i,a,o,c;return y(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,Ft.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 _&&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 ee)if(e.stateType===te.CONNECTED)s.resume();else s.pause()}))}return e.of=function(t,n,r){return dr[t]||(dr[t]={}),dr[t][n.url]||(dr[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r})),dr[t][n.url].ref++,dr[t][n.url]},e.prototype.loadMetadata=function(){return g(this,void 0,void 0,(function(){var e;return y(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}:void 0,t.label=2;case 2:return[2]}}))}))},e.prototype.saveMetadata=function(){return g(this,void 0,void 0,(function(){return y(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 g(this,void 0,void 0,(function(){return y(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=void 0,[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 dr[this._iid][this._channel.url])},e}(),fr=function(t){function n(e){var n,s,i,a,o,u,c=this;return(c=t.call(this)||this).method=D.GET,c.path="".concat(re(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}(F),_r=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 bt(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 bt(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}(R),vr=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},mr=function(e,t,n){if(e.length>0){for(var r=vr(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:gr(e[a],t,n)>=0?a:a+1,oldPosition:r}}return{place:e.length,oldPosition:-1}},gr=function(e,t,n){switch(n){case Ge.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 Ge.CHRONOLOGICAL:return t.createdAt-e.createdAt;case Ge.CHANNEL_NAME_ALPHABETICAL:var r=e.name.localeCompare(t.name);return 0===r?e.createdAt-t.createdAt:r;default:return 0}},yr=function(e,t){return t instanceof Ct?e.findIndex((function(e){return e instanceof Ct&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},Cr=function(e,t){return e.findIndex((function(e){return e.messageId===t}))},Er=function(e,t){if(e.length>0){for(var n=0,r=e.length-1,s=Math.floor((n+r)/2);n0)r=s,s=Math.floor((n+r)/2);else{if(!(i<0))return s;n=s+1,s=Math.floor((n+r)/2)}}return e[s].createdAt>t.createdAt?s:s+1}return e.length},br=6e5;!function(e){e.CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api"}(sr||(sr={}));var Mr,Nr,Sr,Ur=function(){function e(){}return e.prototype._invokeResponse=function(e,t,n){var r=this;Y((function(){return g(r,void 0,void 0,(function(){return y(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}(),Tr=function(){function e(e,t){var n=t.channel,r=t.filter,s=t.startingPoint,i=t.limit,a=this;this._messages=[],this._unsentMessages=[],this._iid=e,this._key="mc-".concat(oe()),this._isDisposed=!1,this.filter=null!=r?r:new Je,this._channel=n,this._syncRange=new er({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof s?s:Date.now()+br,this._limit=i||De;var o=rr.of(this._iid);o.subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t,n){var r=vr(e,a._channel);if(r>=0){switch(a._channel=e[r],t){case ze.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})),J.EVENT_MESSAGE_OFFSET_UPDATED)}break}}!s&&a._messages.length>0&&a._removeMessagesFromView(a._messages.map((function(e){return e.messageId})),J.EVENT_MESSAGE_OFFSET_UPDATED);break;case ze.EVENT_CHANNEL_UNMUTED:var c=n;j.of(a._iid).sdkState.userId===c&&a._clearCheckMyMutedTimer();break;case ze.EVENT_CHANNEL_MUTED:var l=n;j.of(a._iid).sdkState.userId===l&&-1!==a.channel._myMutedRemainingTime&&a._startCheckMyMutedTimer(a.channel._myMutedRemainingTime);break;case ze.EVENT_CHANNEL_LEFT:a.channel.isPublic&&a._clearCheckMyMutedTimer()}Y((function(){return g(a,void 0,void 0,(function(){var e,n;return y(this,(function(r){return e=new ar(t),tt(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(),Y((function(){return g(a,void 0,void 0,(function(){var e,n;return y(this,(function(r){return e=new ar(t),(null===(n=this._handler)||void 0===n?void 0:n.onChannelDeleted)&&this._handler.onChannelDeleted(e,this.channel.url),[2]}))}))})))}}),o.subscribeMessageEvent(this._key,{onUpdate:function(e,t){var n,r,s=[],i=[];try{for(var o=C(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(se(t)){if(s.length>0)switch(t){case J.LOCAL_MESSAGE_CANCELED:case J.LOCAL_MESSAGE_RESEND_STARTED:case J.EVENT_MESSAGE_SENT_FAILED:case J.EVENT_MESSAGE_SENT_SUCCESS:case J.EVENT_MESSAGE_UPDATED:case J.EVENT_MESSAGE_THREADINFO_UPDATED:case J.EVENT_MESSAGE_REACTION_UPDATED:case J.SYNC_MESSAGE_CHANGELOGS:a._updateMessagesToView(s,t);break;case J.EVENT_MESSAGE_SENT_PENDING:a._addMessagesToView(s,t);break;case J.EVENT_MESSAGE_RECEIVED:a.hasNext||a._addMessagesToView(s,t);break;case J.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 We({channels:[this._channel],source:ze.CHANNEL_LASTACCESSEDAT_UPDATED})),!this._channel.isSuper&&c.localCacheEnabled&&(this._backgroundSync=cr.of(this._iid,this._channel),this._backgroundSync.resume(this._startingPoint)),this._changelogSync=hr.of(this._iid,this._channel),this._changelogSync.resume(),this._pollChangelogSync=pr.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new ir(this._key,(function(e){return g(a,void 0,void 0,(function(){var t,n,r,s,i;return y(this,(function(a){switch(a.label){case 0:return[4,this._getRemoteMessages(e,{prevLimit:this._limit,source:J.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,v([],m(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,v([],m(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 ee)switch(e.stateType){case te.CONNECTED:a._refreshChannel(ze.SYNC_CHANNEL_CHANGELOGS),S((function(){return g(a,void 0,void 0,(function(){var e;return y(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 te.LOGOUT:a.dispose();break;default:a._clearCheckMyMutedTimer(),a._prevFill.stop(),a._nextFill.stop()}})),j.of(this._iid).statLogCollector.put(new ie({type:ae.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 v([],m(this._messages),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"failedMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===ue.FAILED}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pendingMessages",{get:function(){return this._unsentMessages.filter((function(e){return e.sendingStatus===ue.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,v(v([],m(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,v(v([],m(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=C(i),c=u.next();!c.done;c=u.next()){var l=c.value;if(t===J.SYNC_MESSAGE_FILL){if(l.messageId>0){if((f=yr(this._messages,l))<0){yr(this._unsentMessages,l)<0&&a.push(l);var h=Er(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof Ct){(f=yr(this._unsentMessages,l))<0&&yr(this._messages,l)<0&&(this._unsentMessages.push(l),a.push(l))}}else if(l.messageId>0){if((f=yr(this._messages,l))<0){var d=yr(this._unsentMessages,l);d<0?a.push(l):(this._unsentMessages.splice(d,1),o.push(l));h=Er(this._messages,l);this._messages.splice(h,0,l)}else o.push(l),this._messages[f]=l;if(l.updatedAt>0){var p=this._updateChildMessagesInView(l);o.push.apply(o,v([],m(p),!1))}}else if(l instanceof Ct){var f;(f=yr(this._unsentMessages,l))<0?yr(this._messages,l)<0&&(this._unsentMessages.push(l),a.push(l)):(o.push(l),this._unsentMessages[f]=l)}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}se(t)&&Y((function(){return g(s,void 0,void 0,(function(){var e,n,r;return y(this,(function(s){return e=new or(t),a.length>0&&(null===(n=this._handler)||void 0===n||n.onMessagesAdded(e,this.channel,a)),o.length>0&&(null===(r=this._handler)||void 0===r||r.onMessagesUpdated(e,this.channel,o)),[2]}))}))}))},e.prototype._updateChildMessagesInView=function(e){var t=[];return this._messages.forEach((function(n){n.parentMessageId===e.messageId&&n.applyParentMessage(e)&&t.push(n)})),t},e.prototype._updatePollsToView=function(e,t){var n,r,s=this,i=[];try{for(var a=C(e),o=a.next();!o.done;o=a.next()){var u=o.value,c=Cr(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&&se(t)&&Y((function(){return g(s,void 0,void 0,(function(){var e,n;return y(this,(function(r){return e=new or(t),i.length>0&&(null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,i)),[2]}))}))})),i},e.prototype._applyPollUpdateEventToView=function(e,t){var n=this,r=Cr(this._messages,e.messageId);if(r>=0){var s=this._messages[r];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollUpdateEvent(e)&&se(t)&&Y((function(){return g(n,void 0,void 0,(function(){var e,n;return y(this,(function(r){return e=new or(t),null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,[s]),[2]}))}))}))}},e.prototype._applyPollVoteEventToView=function(e,t){var n=this,r=Cr(this._messages,e.messageId);if(r>=0){var s=this._messages[r];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollVoteEvent(e)&&se(t)&&Y((function(){return g(n,void 0,void 0,(function(){var e,n;return y(this,(function(r){return e=new or(t),null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,[s]),[2]}))}))}))}},e.prototype._updateMessagesToView=function(e,t){var n,r,s=this,i=[],a=[],o=[];try{for(var u=C(e),c=u.next();!c.done;c=u.next()){var l,h=c.value;if(h.messageId>0)if((l=yr(this._messages,h))>=0)a.push(h),this._messages[l]=h;else{var d=yr(this._unsentMessages,h);if(d>=0){var p=this._unsentMessages.splice(d,1);if(this.hasNext&&p.length>0)o.push(p[0]);else{a.push(h);var f=Er(this._messages,h);this._messages.splice(f,0,h)}}else{var _=this._messages.map((function(e){return e.createdAt}));(h.createdAtMath.max.apply(Math,v([],m(_),!1))&&!this._hasNext)&&i.push(h)}}else if(h instanceof Ct)(l=yr(this._unsentMessages,h))>=0&&(a.push(h),this._unsentMessages[l]=h)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}return se(t)&&Y((function(){return g(s,void 0,void 0,(function(){var e,n,r;return y(this,(function(s){return e=new or(t),a.length>0?null===(n=this._handler)||void 0===n||n.onMessagesUpdated(e,this.channel,a):o.length>0?null===(r=this._handler)||void 0===r||r.onMessagesDeleted(e,this.channel,[],o):i.length>0&&this._addMessagesToView(i,t),[2]}))}))})),a},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=C(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 se(t)&&a.length>0&&Y((function(){return g(s,void 0,void 0,(function(){var e,n;return y(this,(function(r){return e=new or(t),null===(n=this._handler)||void 0===n||n.onMessagesDeleted(e,this.channel,i,a),[2]}))}))})),i},e.prototype._removeUnsentMessageFromView=function(e,t){var n=this._unsentMessages.findIndex((function(t){return t.reqId===e}));n>=0&&this._unsentMessages.splice(n,1)},e.prototype._getLocalMessages=function(e,t){var n=t.prevLimit,r=void 0===n?0:n,s=t.nextLimit,i=void 0===s?0:s,a=t.inclusive,o=void 0===a||a;return g(this,void 0,void 0,(function(){var t,n,s,a,u,c;return y(this,(function(l){switch(l.label){case 0:return t=rr.of(this._iid),n=[],o?[4,t._getExactlyMatchingMessagesForTokenFromCache(this._channel.url,e,this.filter)]:[3,2];case 1:n=l.sent(),l.label=2;case 2:return r>0?[4,t.getMessagesFromCache(this._channel.url,e,"prev",this.filter,r,!1)]:[3,4];case 3:return a=l.sent(),[3,5];case 4:a=[],l.label=5;case 5:return s=a,i>0?[4,t.getMessagesFromCache(this._channel.url,e,"next",this.filter,i,!1)]:[3,7];case 6:return c=l.sent(),[3,8];case 7:c=[],l.label=8;case 8:return u=c,[2,v(v(v([],m(n),!1),m(s),!1),m(u),!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,a=t.nextLimit,o=void 0===a?0:a,u=t.source,c=void 0===u?J.REQUEST_MESSAGE:u,l=t.reverse,h=void 0!==l&&l,d=t.checkingContinuousMessages,p=void 0!==d&&d;return g(this,void 0,void 0,(function(){var t,n;return y(this,(function(a){switch(a.label){case 0:return t=Ut.of(this._iid),r>0||o>0?[4,t._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,e,s(i(i({},this.filter),{isInclusive:!0,reverse:h,prevResultSize:r,nextResultSize:o,includeMetaArray:!0,includeReactions:!0,includeThreadInfo:!0,includeParentMessageInfo:!0})),c,p)]:[3,2];case 1:return n=a.sent(),[3,3];case 2:n={messages:[],isContinuousMessages:!1},a.label=3;case 3:return[2,n]}}))}))},e.prototype._checkHugeGap=function(){var e;return g(this,void 0,void 0,(function(){var t,n,r,s,a,o,u,c,l,h,d,p,f,C,E,b,M,N,S,U,T=this;return y(this,(function(A){switch(A.label){case 0:return this._messages.length>0?(t=this._syncRange.top,n=this.viewTop,r=this._syncRange.bottom,s=this.hasNext?this.viewBottom:Number.MAX_SAFE_INTEGER,[4,(a=rr.of(this._iid)).getCachedMessageCountBetween(this._channel.url,this.filter,n,t)]):[3,4];case 1:return o=A.sent(),[4,a.getCachedMessageCountBetween(this._channel.url,this.filter,r,s)];case 2:return u=A.sent(),[4,ce((function(){return g(T,void 0,void 0,(function(){var e,a,c,l,h,d,p,f,_,C,E,b,M,N,S,U,T,A,I,w,D,k=this;return y(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 fr(i({channelUrl:this._channel.url,channelType:this._channel.channelType,prevStart:n,prevEnd:t,prevCount:o,nextStart:r,nextEnd:s,nextCount:u,checkingContinuousMessages:l.localCacheEnabled},this.filter)),[4,c.send(h)];case 1:return d=P.sent(),p=d.as(_r),f=p.isHugeGap,_=p.prevMessages,C=void 0===_?[]:_,E=p.prevHasMore,b=p.isContinuousPrevMessages,M=p.nextMessages,N=void 0===M?[]:M,S=p.nextHasmore,U=p.isContinuousNextMessages,f?Y((function(){return g(k,void 0,void 0,(function(){var e;return y(this,(function(t){return null===(e=this._handler)||void 0===e||e.onHugeGapDetected(),[2]}))}))})):(T=this.viewTop,A=this.viewBottom,I=Math.min.apply(Math,v([Number.MAX_SAFE_INTEGER,T],m(C.map((function(e){return e.createdAt}))),!1)),w=Math.max.apply(Math,v([0,A],m(N.map((function(e){return e.createdAt}))),!1)),a.dispatch(new L({messages:C,source:J.SYNC_MESSAGE_FILL})),a.dispatch(new L({messages:N,source:J.SYNC_MESSAGE_FILL})),this._syncRange.extends(I,w),(b||U)&&(null===(D=this._backgroundSync)||void 0===D||D.range.extends(I,w)),E&&this._prevFill.start(I),S&&this._nextFill.start(w)),[2]}}))}))}),1)];case 3:return A.sent(),[3,8];case 4:c=j.of(this._iid).cacheContext,l=Math.floor(this._limit/2),h=Date.now(),A.label=5;case 5:return A.trys.push([5,7,,8]),[4,this._getRemoteMessages(h,{prevLimit:l,nextLimit:l,source:J.SYNC_MESSAGE_FILL,checkingContinuousMessages:c.localCacheEnabled})];case 6:if(d=A.sent(),p=d.messages,f=d.isContinuousMessages,p.length>0){for(C=p.map((function(e){return e.createdAt})),E=0,b=0,M=0;M=h&&b++;this._hasPrevious=E>=l,this._hasNext=b>=l,(U=this._syncRange).extends.apply(U,v([],m(C),!1)),f&&(null===(e=this._backgroundSync)||void 0===e||e.range.extends(this._syncRange.top,this._syncRange.bottom)),this._addMessagesToView(p,J.SYNC_MESSAGE_FILL)}else this._hasPrevious=!1,this._hasNext=!1;return[3,8];case 7:return(S=A.sent())instanceof _&&S.code===X.NOT_FOUND_IN_DATABASE&&(this._hasPrevious=!1,this._hasNext=!1),[3,8];case 8:return[2]}}))}))},e.prototype._loadUnsentMessages=function(){return g(this,void 0,void 0,(function(){var e,t;return y(this,(function(n){switch(n.label){case 0:return e=rr.of(this._iid),t=this,[4,e.getUnsentMessagesFromCache(this._channel.url,this.filter)];case 1:return t._unsentMessages=n.sent(),[2]}}))}))},e.prototype._hasPollMessage=function(){return g(this,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,rr.of(this._iid).getPollMessagesFromCache(this._channel.url,Date.now()+br,this.filter,1)];case 1:return e.sent().length>0?[2,!0]:[2,!1]}}))}))},e.prototype._refreshChannel=function(e){rr.of(this._iid).refreshChannel(this.channel.url,!0,e)},e.prototype._startCheckMyMutedTimer=function(e){var t=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return g(t,void 0,void 0,(function(){var e,t,n,r;return y(this,(function(s){switch(s.label){case 0:this._checkMyMutedStateTimer=void 0,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=ns.UNMUTED,n=new ar(ze.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=void 0)},e.prototype.initialize=function(e){var t=this,n=new Ur;this._messages=[],this._unsentMessages=[],this._syncRange=new er({}),this._hasNext=!0,this._hasPrevious=!0,this._refreshChannel(ze.REFRESH_CHANNEL),S((function(){return g(t,void 0,void 0,(function(){var e;return y(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===sr.CACHE_AND_REPLACE_BY_API)this._getLocalMessages(this._startingPoint,{prevLimit:r,nextLimit:r}).then((function(e){return g(t,void 0,void 0,(function(){var t;return y(this,(function(r){switch(r.label){case 0:return t=this._filterUnderOffsetMessage(e),this._addMessagesToView(t,J.REQUEST_MESSAGE),[4,this._loadUnsentMessages()];case 1:return r.sent(),n._invokeResponse("local",null,t),[2]}}))}))})).catch((function(e){if(K(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,d=0;dt._startingPoint&&h++}t._hasPrevious=l>=r,t._hasNext=h>=r,(s=t._syncRange).extends.apply(s,v([],m(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,J.REQUEST_MESSAGE)}else t._hasPrevious=!1,t._hasNext=!1;n._invokeResponse("remote",null,u)})).catch((function(e){if(K(e))throw e;n._invokeResponse("remote",e,null)}))}));var s=j.of(this._iid),i=s.cacheContext;return s.statLogCollector.put(new ie({type:ae.FEATURE_LOCALCACHE,data:{use_local_cache:i.localCacheEnabled,collection_interface:{message_init_policy:e}}})),n},e.prototype.loadPrevious=function(){return g(this,void 0,void 0,(function(){var e,t,n,r=this;return y(this,(function(s){switch(s.label){case 0:if(this._isDisposed)throw new _({code:X.COLLECTION_DISPOSED,message:"Collection has been disposed."});return this._hasPrevious?(e=Math.floor(this._limit/2),t=this.viewTop,n=[],[4,S((function(){return g(r,void 0,void 0,(function(){var r;return y(this,(function(s){switch(s.label){case 0:return r=this._filterUnderOffsetMessage,[4,this._getLocalMessages(t,{prevLimit:e,inclusive:!1})];case 1:return n=r.apply(this,[s.sent()]),[2]}}))}))}))]):[2,[]];case 1:return s.sent(),n.length=e,n.length>0&&((i=this._syncRange).extends.apply(i,v([],m(n.map((function(e){return e.createdAt}))),!1)),(null===(a=this._backgroundSync)||void 0===a?void 0:a.range.overlap(this._syncRange))&&s.isContinuousMessages&&(null===(o=this._backgroundSync)||void 0===o||o.range.extends(this._syncRange.top))),[2]}}))}))}))]:[3,3];case 2:return s.sent(),this._addMessagesToView(n,J.REQUEST_MESSAGE),[3,4];case 3:this._hasPrevious=n.length>=e,n.length>0&&this._addMessagesToView(n,J.REQUEST_MESSAGE),s.label=4;case 4:return[2,n]}}))}))},e.prototype.loadNext=function(){var e;return g(this,void 0,void 0,(function(){var t,n,r,s=this;return y(this,(function(i){switch(i.label){case 0:if(this._isDisposed)throw new _({code:X.COLLECTION_DISPOSED,message:"Collection has been disposed."});return this._hasNext?(t=Math.floor(this._limit/2),n=this.viewBottom,r=[],[4,S((function(){return g(s,void 0,void 0,(function(){var e;return y(this,(function(s){switch(s.label){case 0:return e=this._filterUnderOffsetMessage,[4,this._getLocalMessages(n,{nextLimit:t,inclusive:!1})];case 1:return r=e.apply(this,[s.sent()]),[2]}}))}))}))]):[2,[]];case 1:return i.sent(),r.length=t,r.length>0&&((i=this._syncRange).extends.apply(i,v([],m(r.map((function(e){return e.createdAt}))),!1)),(null===(a=this._backgroundSync)||void 0===a?void 0:a.range.overlap(this._syncRange))&&s.isContinuousMessages&&(null===(o=this._backgroundSync)||void 0===o||o.range.extends(this._syncRange.bottom))),[2]}}))}))}))]:[3,3];case 2:return i.sent(),this._addMessagesToView(r,J.REQUEST_MESSAGE),[3,4];case 3:this._hasNext=r.length>=t,r.length>0&&this._addMessagesToView(r,J.REQUEST_MESSAGE),i.label=4;case 4:return[2,r]}}))}))},e.prototype.removeFailedMessage=function(e){return g(this,void 0,void 0,(function(){var t;return y(this,(function(n){switch(n.label){case 0:if(this._isDisposed)throw new _({code:X.COLLECTION_DISPOSED,message:"Collection has been disposed."});return[4,rr.of(this._iid).removeFailedMessageFromCache(e)];case 1:return n.sent(),(t=this._unsentMessages.findIndex((function(t){return t.reqId===e})))>-1&&this._unsentMessages.splice(t,1),[2]}}))}))},e.prototype.dispose=function(){var e,t,n;if(!this._isDisposed){this._isDisposed=!0;var r=j.of(this._iid),s=r.cacheContext,i=r.dispatcher;this._messages=[],this._clearCheckMyMutedTimer(),this._channel._updateMessageCollectionLastAccessedAt(),i.dispatch(new We({channels:[this._channel],source:ze.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=rr.of(this._iid);a.unsubscribeGroupChannelEvent(this._key),a.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}},e}(),Ar={coverUrl:void 0,coverImage:void 0,isDistinct:void 0,isPublic:void 0,isDiscoverable:void 0,accessCode:void 0,name:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,messageSurvivalSeconds:void 0},Ir=function(t){function n(e){var n=this,r=e.channelUrl,s=e.token,i=e.limit,a=e.order,o=e.mutedMemberFilter,u=e.memberStateFilter,c=e.nicknameStartsWithFilter,l=e.operatorFilter;return(n=t.call(this)||this).method=D.GET,n.path="".concat(O,"/").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}(F),wr=function(t){function n(e,n){var r=t.call(this,e,n)||this;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 zt(e,t)}))),r}return e(n,t),n}(R);!function(e){e.ALL="all",e.MUTED="muted",e.UNMUTED="unmuted"}(Mr||(Mr={})),function(e){e.MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",e.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical"}(Nr||(Nr={})),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"}(Sr||(Sr={}));var Lr=function(t){function n(e,n,r){var s,i,a,o,c=this;return(c=t.call(this,e,n,u.GROUP,r)||this).mutedMemberFilter=Mr.ALL,c.memberStateFilter=Sr.ALL,c.nicknameStartsWithFilter=null,c.operatorFilter=qt.ALL,c.order=Nr.MEMBER_NICKNAME_ALPHABETICAL,c.mutedMemberFilter=null!==(s=r.mutedMemberFilter)&&void 0!==s?s:Mr.ALL,c.memberStateFilter=null!==(i=r.memberStateFilter)&&void 0!==i?i:Sr.ALL,c.nicknameStartsWithFilter=null!==(a=r.nicknameStartsWithFilter)&&void 0!==a?a:null,c.order=null!==(o=r.order)&&void 0!==o?o:Nr.MEMBER_NICKNAME_ALPHABETICAL,c}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&a(Mr,this.mutedMemberFilter)&&a(Sr,this.memberStateFilter)&&(b("string",this.nicknameStartsWithFilter)||null===this.nicknameStartsWithFilter)&&a(qt,this.operatorFilter)&&a(Nr,this.order)},n.prototype.next=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,a,o;return y(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 Ir(s(i(i({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=u.sent(),r=n.as(wr),a=r.members,o=r.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},n}(le),Dr=function(t){function n(e){var n=this,r=e.channelUrl,s=e.userId,i=e.accessCode;return(n=t.call(this)||this).method=D.PUT,n.path="".concat(O,"/").concat(encodeURIComponent(r),"/accept"),n.params={user_id:s,access_code:i},n}return e(n,t),n}(F),kr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new cs(e,n),r.channel.myMemberState=Rt.JOINED,r}return e(n,t),n}(R),Pr=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=D.PUT,n.path="".concat(O,"/").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}(F),Fr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.channel=new cs(e,n),r}return e(n,t),n}(R),Rr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=D.DELETE,n.path="".concat(O,"/").concat(encodeURIComponent(r)),n}return e(n,t),n}(F);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(R);var xr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=D.DELETE,n.path="".concat(O,"/").concat(encodeURIComponent(r),"/hide"),n}return e(n,t),n}(F);!function(t){function n(){return null!==t&&t.apply(this,arguments)||this}e(n,t)}(R);var Or=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=e.countPreference,i=t.call(this)||this;return i.method=D.PUT,i.path="".concat(k,"/").concat(encodeURIComponent(n),"/count_preference/").concat(encodeURIComponent(r)),i.params={count_preference:s},i}return e(n,t),n}(F),Hr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.countPreference=n.count_preference,r}return e(n,t),n}(R),Gr=function(t){function n(e){var n=this,r=e.channelUrl;return(n=t.call(this)||this).method=D.PUT,n.path="".concat(O,"/").concat(encodeURIComponent(r),"/reset_user_history"),n}return e(n,t),n}(F),Vr=function(t){function n(e,n){var r=t.call(this,e,n)||this,s=n.ts_message_offset;return r.messageOffsetTimestamp=s,r}return e(n,t),n}(R),qr=i(i({},ke),{scheduledAt:void 0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Br=i(i({},Fe),{scheduledAt:void 0}),Wr=function(t){function n(e){var n,i=this;i=t.call(this)||this;var a=[];e.mentionType===he.USERS&&(e.mentionedUserIds?a=e.mentionedUserIds:e.mentionedUsers&&(a=e.mentionedUsers.map((function(e){return e.userId}))));var o=e.channelType,u=e.channelUrl,c=e.scheduledMessageId;return i.method=D.PUT,i.path="".concat(re(o),"/").concat(encodeURIComponent(u),"/scheduled_messages/").concat(encodeURIComponent(c)),i.params=r(s({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:de.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 Tt.payloadify(e)})):[],custom_type:e.customType,data:e.data,require_auth:e.requireAuth,mention_type:e.mentionType,mentioned_user_ids:a,sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return At.payloadify(e)})),apple_critical_alert_options:e.appleCriticalAlertOptions?It.payloadify(e.appleCriticalAlertOptions):null,push_option:e.pushNotificationDeliveryOption})),i}return e(n,t),n}(F),zr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new Nt(e,n),r}return e(n,t),n}(R),jr=function(t){function n(e){var n,i=this;i=t.call(this)||this;var a=[];e.mentionType===he.USERS&&(e.mentionedUserIds?a=e.mentionedUserIds:e.mentionedUsers&&(a=e.mentionedUsers.map((function(e){return e.userId}))));var o=e.channelType,u=e.channelUrl,c=e.scheduledMessageId;return i.method=D.PUT,i.path="".concat(re(o),"/").concat(encodeURIComponent(u),"/scheduled_messages/").concat(encodeURIComponent(c)),i.params=r(s({req_id:e.reqId,scheduled_at:e.scheduledAt,message_type:de.USER,message:e.message,custom_type:e.customType,data:e.data,mention_type:e.mentionType,mentioned_user_ids:a,sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return At.payloadify(e)})),apple_critical_alert_options:e.appleCriticalAlertOptions?It.payloadify(e.appleCriticalAlertOptions):null,target_langs:e.translationTargetLanguages,push_option:e.pushNotificationDeliveryOption})),i}return e(n,t),n}(F);!function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.message=new Mt(e,n),r}e(n,t)}(R);var Qr=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,i=e.scheduledMessageId;return n.method=D.DELETE,n.path="".concat(re(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i)),n}return e(n,t),n}(F),Kr=function(t){function n(e){var n=t.call(this)||this,r=e.channelType,s=e.channelUrl,i=e.scheduledMessageId;return n.method=D.POST,n.path="".concat(re(r),"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i),"/send_now"),n}return e(n,t),n}(F),Yr=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=e.pushTriggerOption,i=t.call(this)||this;return i.method=D.PUT,i.path="".concat(k,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(r)),i.params={push_trigger_option:s},i}return e(n,t),n}(F),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}(R),Xr=function(t){function n(e){var n=e.userId,r=e.channelUrl,s=t.call(this)||this;return s.method=D.GET,s.path="".concat(k,"/").concat(encodeURIComponent(n),"/push_preference/").concat(encodeURIComponent(r)),s}return e(n,t),n}(F),Zr=function(t){function n(e,n){var r=t.call(this,e,n)||this;return r.pushTriggerOption=n.push_trigger_option,r.enabled=n.enable,r}return e(n,t),n}(R),$r=function(t){function n(e){var n=e.channelType,r=e.channelUrl,s=e.messageId,i=t.call(this)||this;return i.method=D.POST,i.path="".concat(re(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),i}return e(n,t),n}(F);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(R);var es=function(t){function n(e){var n=e.channelType,r=e.channelUrl,s=e.messageId,i=t.call(this)||this;return i.method=D.DELETE,i.path="".concat(re(n),"/").concat(encodeURIComponent(r),"/messages/").concat(s,"/pin"),i}return e(n,t),n}(F);!function(t){function n(e,n){return t.call(this,e,n)||this}e(n,t)}(R);var ts,ns,rs,ss=function(t){function n(e,n){var r=t.call(this,e)||this;return r.message=bt(e,n.message),r}return e(n,t),n}(h),is=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=D.GET,n.path="".concat(re(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}(F),as=function(t){function n(e,n){var r=t.call(this,e,n)||this,s=n.pinned_messages,i=n.has_more,a=n.next;return r.pinnedMessages=s.map((function(t){return new ss(e,t)})),r.hasMore=i,r.token=a,r}return e(n,t),n}(R),os=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)&&b("boolean",this.includeMetaArray,!0)&&b("boolean",this.includeReactions,!0)&&b("boolean",this.includeParentMessageInfo,!0)&&b("boolean",this.includeThreadInfo,!0)&&b("boolean",this.includePollDetails,!0)},n.prototype.next=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,s,a,o;return y(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 is(i(i({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=u.sent(),r=n.as(as),s=r.pinnedMessages,a=r.hasMore,o=r.token,this._token=o,this._hasNext=!!a,this._isLoading=!1,[2,s];case 2:return[2,[]];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},n}(le);!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"}(ts||(ts={})),function(e){e.MUTED="muted",e.UNMUTED="unmuted"}(ns||(ns={})),function(e){e.UNHIDDEN="unhidden",e.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",e.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide"}(rs||(rs={}));var us,cs=function(t){function n(e,n){var r,s,l,h,d,p,f,_,g,y,C,E,M,N,S,U,T,A,I,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=rs.UNHIDDEN,w.lastMessage=null,w.messageOffsetTimestamp=0,w.messageSurvivalSeconds=-1,w.myMemberState=Rt.NONE,w.myRole=o.NONE,w.myMutedState=ns.UNMUTED,w.myLastRead=0,w.myCountPreference=ts.ALL,w.myPushTriggerOption=fe.DEFAULT,w.inviter=null,w.invitedAt=0,w.joinedAt=0,w.pinnedMessageIds=[],w.lastPinnedMessage=null,w._pinnedMessagesUpdatedAt=0,w._myMutedRemainingTime=-1,w.channelType=u.GROUP,w.isDistinct=null!==(s=n.is_distinct)&&void 0!==s&&s,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!==(d=n.is_exclusive)&&void 0!==d&&d,w.isPublic=null!==(p=n.is_public)&&void 0!==p&&p,w.isDiscoverable=null!==(f=n.is_discoverable)&&void 0!==f?f:w.isPublic,w.isAccessCodeRequired=null!==(_=n.is_access_code_required)&&void 0!==_&&_,w.isPushEnabled=null!==(g=n.is_push_enabled)&&void 0!==g&&g,Array.isArray(n.members)&&(r=w.members).push.apply(r,v([],m(n.members.map((function(e){return new zt(w._iid,e)}))),!1)),w.memberCount=null!==(y=n.member_count)&&void 0!==y?y:0,w.joinedMemberCount=null!==(C=n.joined_member_count)&&void 0!==C?C:0,w.hiddenState=a(rs,n.hidden_state)?n.hidden_state:rs.UNHIDDEN,w.messageOffsetTimestamp=null!==(E=n.ts_message_offset)&&void 0!==E?E:0,w.messageSurvivalSeconds=null!==(M=n.message_survival_seconds)&&void 0!==M?M:-1,w.lastMessage=n.last_message?bt(w._iid,i({channel_type:w.channelType},n.last_message)):null,n.read_receipt&&Object.keys(n.read_receipt).forEach((function(e){b("number",n.read_receipt[e])&&w._updateUnreadMemberState(e,n.read_receipt[e])})),n.delivery_receipt&&Object.keys(n.delivery_receipt).forEach((function(e){b("number",n.delivery_receipt[e])&&w._updateUndeliveredMemberState(e,n.delivery_receipt[e])})),w.myMemberState=a(Rt,n.member_state)?n.member_state:Rt.NONE,w.myRole=a(o,n.my_role)?n.my_role:o.NONE,a(ns,n.is_muted)?w.myMutedState=n.is_muted:b("boolean",n.is_muted)?w.myMutedState=n.is_muted?ns.MUTED:ns.UNMUTED:w.myMutedState=ns.UNMUTED,w.myCountPreference=a(ts,n.count_preference)?n.count_preference:ts.ALL,w.myPushTriggerOption=a(fe,n.push_trigger_option)?n.push_trigger_option:fe.ALL,w.myLastRead=null!==(N=n.user_last_read)&&void 0!==N?N:0,w.inviter=n.inviter?new c(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!==(A=n.unread_mention_count)&&void 0!==A?A:0),w.pinnedMessageIds=null!==(I=n.pinned_message_ids)&&void 0!==I?I:[],w.lastPinnedMessage=n.latest_pinned_message?bt(w._iid,i({channel_type:w.channelType},n.latest_pinned_message)):null,w}return e(n,t),Object.defineProperty(n.prototype,"isHidden",{get:function(){return this.hiddenState!==rs.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=C(this._unreadMemberStateMap),s=r.next();!s.done;s=r.next()){var i=m(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=C(this._undeliveredMemberStateMap),s=r.next();!s.done;s=r.next()){var i=m(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 r(s(i(i({},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 zt.payloadify(e)})),last_message:e.lastMessage?wt(e.lastMessage):null,inviter:e.inviter?c.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,pinned_message_ids:e.pinnedMessageIds,latest_pinned_message:e.lastPinnedMessage?wt(e.lastPinnedMessage):null})))},n.prototype._shouldUpdateLastMessageWith=function(e){return!(e instanceof Ct&&e.parentMessageId>0&&!e.replyToChannel)&&(!this.lastMessage||this.lastMessage.createdAt=0)if(this.myCountPreference===ts.ALL||this.myCountPreference===ts.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===ts.ALL||this.myCountPreference===ts.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 B(this,(function(t){t.cachedUnreadMemberState=e.cachedUnreadMemberState,t.cachedUndeliveredMemberState=e.cachedUndeliveredMemberState}))},n.prototype.createMessageCollection=function(e){return void 0===e&&(e={}),new Tr(this._iid,i({channel:this},e))},n.prototype.createMemberListQuery=function(e){return void 0===e&&(e={}),new Lr(this._iid,this.url,e)},n.prototype.createPinnedMessageListQuery=function(e){return void 0===e&&(e={}),new os(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===Rt.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 zt?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 Ct&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var r=j.of(this._iid).sdkState,s=e.createdAt,i=0;try{for(var a=C(this.members),o=a.next();!o.done;o=a.next()){var u=o.value;if(r.userId!==u.userId&&u.state===Rt.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 Ct?e.sender:null,i=[];return this.members.forEach((function(a){if(t||a.userId!==r.userId&&a.userId!==(null==s?void 0:s.userId)){var o=n._unreadMemberStateMap.get(a.userId);o&&o=t&&(e._typingStatus.delete(i),r=!0)})),r},n.prototype.refresh=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,s,i;return y(this,(function(a){switch(a.label){case 0:return e=j.of(this._iid),t=e.requestQueue,n=e.dispatcher,r=new ln({channelUrl:this.url}),[4,t.send(r)];case 1:return s=a.sent(),i=s.as(hn).channel,this._update(i),n.dispatch(new We({channels:[i],source:ze.REQUEST_CHANNEL})),[2,this]}}))}))},n.prototype.freeze=function(){return g(this,void 0,void 0,(function(){return y(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 We({channels:[this],source:ze.EVENT_CHANNEL_FROZEN,isWebSocketEventComing:!0})),[2]}}))}))},n.prototype.unfreeze=function(){return g(this,void 0,void 0,(function(){return y(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 We({channels:[this],source:ze.EVENT_CHANNEL_UNFROZEN,isWebSocketEventComing:!0})),[2]}}))}))},n.prototype.updateChannel=function(e){return g(this,void 0,void 0,(function(){var t,n,r,s,a,o,u;return y(this,(function(c){switch(c.label){case 0:return t=i(i({},Ar),e),f(function(e){return b("string",e.coverUrl,!0)&&(M(e.coverImage)||b("string",e.coverImage,!0))&&b("boolean",e.isDistinct,!0)&&b("boolean",e.isPublic,!0)&&b("boolean",e.isDiscoverable,!0)&&b("string",e.accessCode,!0)&&b("string",e.name,!0)&&b("string",e.data,!0)&&b("string",e.customType,!0)&&E("string",e.operatorUserIds,!0)&&b("number",e.messageSurvivalSeconds,!0)}(t)).throw(_.invalidParameters),n=j.of(this._iid),r=n.dispatcher,s=n.requestQueue,a=new Pr(i({channelUrl:this.url},t)),[4,s.send(a)];case 1:return o=c.sent(),u=o.as(Fr).channel,this._update(u),r.dispatch(new We({channels:[u],source:ze.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),[2,this]}}))}))},n.prototype.invite=function(e){return g(this,void 0,void 0,(function(){return y(this,(function(t){return f(e.every((function(e){return e instanceof c}))).throw(_.invalidParameters),[2,this.inviteWithUserIds(e.map((function(e){return e.userId})))]}))}))},n.prototype.inviteWithUserIds=function(e){return g(this,void 0,void 0,(function(){var t,n,r,s,i,a;return y(this,(function(o){switch(o.label){case 0:return f(E("string",e)).throw(_.invalidParameters),t=j.of(this._iid),n=t.dispatcher,r=t.requestQueue,s=new Pn({channelUrl:this.url,userIds:e}),[4,r.send(s)];case 1:return i=o.sent(),a=i.as(Fn).channel,this._update(a),n.dispatch(new We({channels:[a],source:ze.EVENT_CHANNEL_INVITED,isWebSocketEventComing:!0})),[2,this]}}))}))},n.prototype.join=function(e){return g(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return y(this,(function(u){switch(u.label){case 0:return f(b("string",e,!0)).throw(_.invalidParameters),t=j.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new In({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(i)];case 1:return a=u.sent(),(o=a.as(wn).channel).myMemberState=this.myMemberState=Rt.JOINED,this._update(o),n.dispatch(new We({channels:[o],source:ze.EVENT_CHANNEL_JOINED,isWebSocketEventComing:!0})),[2,this]}}))}))},n.prototype.leave=function(e){return void 0===e&&(e=!1),g(this,void 0,void 0,(function(){var t,n,r,s;return y(this,(function(i){switch(i.label){case 0:return t=j.of(this._iid),n=t.sdkState,r=t.requestQueue,s=new Dn({channelUrl:this.url,userId:n.userId,shouldRemoveOperatorStatus:e}),[4,r.send(s)];case 1:return i.sent(),this.myMemberState=Rt.NONE,[2]}}))}))},n.prototype.acceptInvitation=function(e){return g(this,void 0,void 0,(function(){var t,n,r,s,i,a,o;return y(this,(function(u){switch(u.label){case 0:return f(b("string",e,!0)).throw(_.invalidParameters),t=j.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new Dr({channelUrl:this.url,userId:r.userId,accessCode:e}),[4,s.send(i)];case 1:return a=u.sent(),(o=a.as(kr).channel).myMemberState=this.myMemberState=Rt.JOINED,this._update(o),n.dispatch(new We({channels:[o],source:ze.EVENT_CHANNEL_ACCEPTED_INVITE,isWebSocketEventComing:!0})),[2,this]}}))}))},n.prototype.declineInvitation=function(){return g(this,void 0,void 0,(function(){var e,t,n,r;return y(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=Rt.NONE,[2,this]}}))}))},n.prototype.sendUserMessage=function(e){var n=this,r=new Dt,s=j.of(this._iid).dispatcher,i=nt.of(this._iid);return t.prototype.sendUserMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(e)})).onFailed((function(e,t){t&&i.completeCurrentAndProcessNextAutoResend(t),r._triggerFailed(e,t)})).onSucceeded((function(e){n.hiddenState===rs.HIDDEN_ALLOW_AUTO_UNHIDE&&(n.hiddenState=rs.UNHIDDEN),i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),rr.of(n._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),s.dispatch(new We({channels:[n],source:ze.EVENT_MESSAGE_SENT})),r._trigger(e)})),r},n.prototype.updateUserMessage=function(e,n){return g(this,void 0,void 0,(function(){var r,s,i,a,o=this;return y(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&&(rr.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),r.dispatch(new We({channels:[this],source:a?ze.EVENT_PINNED_MESSAGE_UPDATED:ze.EVENT_MESSAGE_UPDATED}))),a&&rr.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),r.dispatch(new L({messages:[s],source:J.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},n.prototype._autoResendUserMessage=function(e){var n=this,r=new Dt,s=j.of(this._iid).dispatcher,i=nt.of(this._iid);return t.prototype._autoResendUserMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(e)})).onFailed((function(e,t){i.completeCurrentAndProcessNextAutoResend(t),r._triggerFailed(e,t)})).onSucceeded((function(e){var t=rr.of(n._iid);i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),t.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),s.dispatch(new We({channels:[n],source:ze.EVENT_MESSAGE_SENT})),r._trigger(e)})),r},n.prototype.sendFileMessage=function(e){var n=this,r=new Dt,s=j.of(this._iid).dispatcher,i=nt.of(this._iid);return t.prototype.sendFileMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(e)})).onFailed((function(e,t){t&&i.completeCurrentAndProcessNextAutoResend(t),r._triggerFailed(e,t)})).onSucceeded((function(e){var t=rr.of(n._iid);i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),t.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),s.dispatch(new We({channels:[n],source:ze.EVENT_MESSAGE_SENT})),r._trigger(e)})),r},n.prototype.sendMultipleFilesMessage=function(e){var n=this,r=new Lt,s=j.of(this._iid).dispatcher;return t.prototype.sendMultipleFilesMessage.call(this,e).onPending((function(e){r._trigger(e)})).onFailed((function(e,t){r._triggerFailed(e,t)})).onSucceeded((function(e){var t=rr.of(n._iid);n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),t.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),s.dispatch(new We({channels:[n],source:ze.EVENT_MESSAGE_SENT})),r._trigger(e)})).onFileUploaded((function(e,t,n,s){r._triggerOnFileUploaded(e,t,n,s)})),r},n.prototype.updateFileMessage=function(e,n){return g(this,void 0,void 0,(function(){var r,s,i,a,o=this;return y(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&&(rr.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)})),r.dispatch(new We({channels:[this],source:a?ze.EVENT_PINNED_MESSAGE_UPDATED:ze.EVENT_MESSAGE_UPDATED}))),a&&rr.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(o)})),r.dispatch(new L({messages:[s],source:J.EVENT_MESSAGE_UPDATED})),[2,s]}}))}))},n.prototype._autoResendFileMessage=function(e){var n=this,r=new Dt,s=j.of(this._iid).dispatcher,i=nt.of(this._iid);return t.prototype._autoResendFileMessage.call(this,e).onPending((function(e){i.completeCurrentAndProcessNextAutoResend(e),r._trigger(e)})).onFailed((function(e,t){i.completeCurrentAndProcessNextAutoResend(t),r._triggerFailed(e,t)})).onSucceeded((function(e){var t=rr.of(n._iid);i.completeCurrentAndProcessNextAutoResend(e),n._shouldUpdateLastMessageWith(e)&&(n.lastMessage=e),t.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),s.dispatch(new We({channels:[n],source:ze.EVENT_MESSAGE_SENT})),r._trigger(e)})),r},n.prototype.deleteMessage=function(e){return g(this,void 0,void 0,(function(){return y(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 Ct&&j.of(this._iid).dispatcher.dispatch(new I({reqId:e.reqId,source:J.EVENT_MESSAGE_DELETED})),[2]}}))}))},n.prototype.hide=function(e){return g(this,void 0,void 0,(function(){var t,n,r,s,a,o,u,c;return y(this,(function(l){switch(l.label){case 0:return t=i(i({},Wn),e),f(function(e){return b("boolean",e.hidePreviousMessages,!0)&&b("boolean",e.allowAutoUnhide,!0)}(t)).throw(_.invalidParameters),n=j.of(this._iid),r=n.dispatcher,s=n.sdkState,a=n.requestQueue,o=new zn(i({channelUrl:this.url,userId:s.userId},t)),[4,a.send(o)];case 1:return u=l.sent(),c=u.as(jn).messageOffsetTimestamp,this.hiddenState=t.allowAutoUnhide?rs.HIDDEN_ALLOW_AUTO_UNHIDE:rs.HIDDEN_PREVENT_AUTO_UNHIDE,t.hidePreviousMessages&&this._updateUnreadCount(0,0),c&&(this.messageOffsetTimestamp=c),r.dispatch(new We({channels:[this],source:ze.EVENT_CHANNEL_HIDDEN,isWebSocketEventComing:!0})),[2,this]}}))}))},n.prototype.unhide=function(){return g(this,void 0,void 0,(function(){var e,t,n,r;return y(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=rs.UNHIDDEN,t.dispatch(new We({channels:[this],source:ze.EVENT_CHANNEL_UNHIDDEN,isWebSocketEventComing:!0})),[2,this]}}))}))},n.prototype.delete=function(){return g(this,void 0,void 0,(function(){var e,t;return y(this,(function(n){switch(n.label){case 0:return e=j.of(this._iid).requestQueue,t=new Rr({channelUrl:this.url}),[4,e.send(t)];case 1:return n.sent(),[2]}}))}))},n.prototype.markAsRead=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,s,i,a,o=this;return y(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 Hn({channelUrl:this.url}),[4,r.send(s)];case 1:return i=u.sent(),a=i.as(Gn).readStatus,this._updateUnreadMemberState(t.userId,a.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),rr.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(o)}))),n.dispatch(new We({channels:[this],source:ze.EVENT_CHANNEL_READ})),[2]}}))}))},n.prototype.markAsDelivered=function(){return g(this,void 0,void 0,(function(){var e,t,n,r;return y(this,(function(s){switch(s.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Vn({channelUrl:this.url,userId:t.userId}),[4,n.send(r)];case 1:return s.sent(),[2]}}))}))},n.prototype.startTyping=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,s;return y(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 Kn({channelUrl:this.url,time:this._typingStarted}),t.send(s)),[2]}))}))},n.prototype.endTyping=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,s;return y(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 Jn({channelUrl:this.url,time:this._typingStarted}),t.send(s)),[2]}))}))},n.prototype.createScheduledUserMessage=function(e){e=i(i({},rt),e),f(st(e)).throw(_.invalidParameters);var t=new Dt;return this._createScheduledUserMessage(e,t),t},n.prototype.updateScheduledUserMessage=function(e,t){return g(this,void 0,void 0,(function(){var n,r,s,a;return y(this,(function(o){switch(o.label){case 0:return n=i(i({},Br),t),f(function(e){return Re(e)&&b("number",e.scheduledAt,!0)}(n)).throw(_.invalidParameters),r=j.of(this._iid).requestQueue,s=new jr(i({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,r.send(s)];case 1:return a=o.sent(),[2,a.as(Oe).message]}}))}))},n.prototype.createScheduledFileMessage=function(e){var t=this;e=i(i({},it),e),f(at(e)).throw(_.invalidParameters);var n=Date.now(),r=this._generateRequestId(),s=new Dt;return pe(He).then((function(){var i=t._createPendingScheduledFileMessage(e,r,n);Y((function(){return g(t,void 0,void 0,(function(){return y(this,(function(e){return[2,s._trigger(i)]}))}))}))})),M(e.file)?this._uploadFileAndUpdateParams(e).then((function(){return t._createScheduledFileMessage(e,s,r,n)})):this._createScheduledFileMessage(e,s,r,n),s},n.prototype.updateScheduledFileMessage=function(e,t){return g(this,void 0,void 0,(function(){var n,r,s;return y(this,(function(a){switch(a.label){case 0:return n=i(i({},qr),t),f(function(e){return Pe(e)&&b("number",e.scheduledAt,!0)&&(M(e.file)||b("string",e.fileUrl))&&b("string",e.fileName,!0)&&b("string",e.mimeType,!0)&&b("number",e.fileSize,!0)&&(null===e.thumbnailSizes||void 0===e.thumbnailSizes||e.thumbnailSizes.every((function(e){return b("object",e)&&e.maxWidth>0&&e.maxHeight>0})))}(n)).throw(_.invalidParameters),M(n.file)?[4,this._uploadFileAndUpdateParams(n)]:[3,2];case 1:a.sent(),a.label=2;case 2:return r=new Wr(i({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},n)),[4,j.of(this._iid).requestQueue.send(r)];case 3:return s=a.sent(),[2,s.as(zr).message]}}))}))},n.prototype.cancelScheduledMessage=function(e){return g(this,void 0,void 0,(function(){var t;return y(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.sendScheduledMessageNow=function(e){return g(this,void 0,void 0,(function(){var t;return y(this,(function(n){switch(n.label){case 0:return t=new Kr({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 g(this,void 0,void 0,(function(){var e,t,n,r,s,i;return y(this,(function(a){switch(a.label){case 0:return e=j.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Xr({userId:t.userId,channelUrl:this.url}),[4,n.send(r)];case 1:return s=a.sent(),i=s.as(Zr).pushTriggerOption,this.myPushTriggerOption=i,[2,i]}}))}))},n.prototype.setMyPushTriggerOption=function(e){return g(this,void 0,void 0,(function(){var t,n,r,s,i,o,u;return y(this,(function(c){switch(c.label){case 0:return f(a(fe,e)).throw(_.invalidParameters),t=j.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new Yr({userId:r.userId,channelUrl:this.url,pushTriggerOption:e}),[4,s.send(i)];case 1:return o=c.sent(),u=o.as(Jr).pushTriggerOption,this.myPushTriggerOption=u,n.dispatch(new We({channels:[this],source:ze.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),[2,u]}}))}))},n.prototype.setMyCountPreference=function(e){return g(this,void 0,void 0,(function(){var t,n,r,s,i,o,u;return y(this,(function(c){switch(c.label){case 0:return f(a(ts,e)).throw(_.invalidParameters),t=j.of(this._iid),n=t.dispatcher,r=t.sdkState,s=t.requestQueue,i=new Or({channelUrl:this.url,userId:r.userId,countPreference:e}),[4,s.send(i)];case 1:return o=c.sent(),u=o.as(Hr).countPreference,this.myCountPreference=u,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),n.dispatch(new We({channels:[this],source:ze.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),[2,u]}}))}))},n.prototype.resetMyHistory=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,s,i;return y(this,(function(a){switch(a.label){case 0:return e=j.of(this._iid),t=e.dispatcher,n=e.requestQueue,r=new Gr({channelUrl:this.url}),[4,n.send(r)];case 1:return s=a.sent(),i=s.as(Vr).messageOffsetTimestamp,this.messageOffsetTimestamp=i,this.lastMessage&&this.lastMessage.createdAt0).throw(_.invalidParameters),t=j.of(this._iid).requestQueue,n=new $r({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(n)];case 1:return r.sent(),[2]}}))}))},n.prototype.unpinMessage=function(e){return g(this,void 0,void 0,(function(){var t,n;return y(this,(function(r){switch(r.label){case 0:return f(b("number",e)&&e>0).throw(_.invalidParameters),t=j.of(this._iid).requestQueue,n=new es({channelType:this.channelType,channelUrl:this.url,messageId:e}),[4,t.send(n)];case 1:return r.sent(),[2]}}))}))},n.prototype._uploadFileAndUpdateParams=function(e){return g(this,void 0,void 0,(function(){var t,n,r,s,i,a,o,u,c,l,h;return y(this,(function(d){switch(d.label){case 0:return M(e.file)?(t=j.of(this._iid).requestQueue,n=new Pt({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(kt),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}(xe),ls={},hs=function(){function e(e){var t=e._iid,n=e.limit,r=void 0===n?100:n,s=this;this.ref=0,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 ir(l,(function(){return g(s,void 0,void 0,(function(){var e,t,n,r,s,i,a,o,u,l;return y(this,(function(h){switch(h.label){case 0:return e={hasNext:!0,nextToken:""},[4,this.loadMetadata()];case 1:if(h.sent(),c.debug("channel background sync from",null===(a=this._metadata)||void 0===a?void 0:a.token),null===(o=this._metadata)||void 0===o?void 0:o.completed)return[3,9];h.label=2;case 2:return h.trys.push([2,5,,8]),[4,rr.of(this._iid).getMyGroupChannels(null!==(l=null===(u=this._metadata)||void 0===u?void 0:u.token)&&void 0!==l?l:"",{includeEmpty:!0,order:Ge.CHRONOLOGICAL},this._limit,ze.SYNC_CHANNEL_BACKGROUND)];case 3:return t=h.sent(),n=t.channels,r=t.token,e.hasNext=n.length>=this._limit&&!!r,e.nextToken=r,this._metadata&&(this._metadata.token=r,(i=this._metadata.range).extends.apply(i,v([],m(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 h.sent(),[3,8];case 5:return s=h.sent(),c.debug("channel background sync error",s),s instanceof _&&s.isInvalidTokenError?[4,this.clearMetaData()]:[3,7];case 6:h.sent(),h.label=7;case 7:throw s;case 8:return[3,10];case 9:e.hasNext=!1,e.nextToken="",h.label=10;case 10:return[2,e]}}))}))})),this._connectionEventContext=u.on((function(e){if(e instanceof ee)if(e.stateType===te.CONNECTED)s.resume();else s.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])},Object.defineProperty(e.prototype,"range",{get:function(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new er({})},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 g(this,void 0,void 0,(function(){var e;return y(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 er(e?e.range:{top:Number.MAX_SAFE_INTEGER,bottom:0}),completed:!!e&&e.completed},t.label=2;case 2:return[2,this._metadata]}}))}))},e.prototype.saveMetadata=function(){return g(this,void 0,void 0,(function(){return y(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 g(this,void 0,void 0,(function(){return y(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=void 0,[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 ls[this._iid])},e}(),ds={},ps=function(){function e(e){var t=e._iid,n=this;this.ref=0,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 ir(u,(function(){return g(n,void 0,void 0,(function(){var e,t,n,r,s,a,o,u;return y(this,(function(c){switch(c.label){case 0:return e={hasNext:!0,nextToken:0},[4,this.loadMetadata()];case 1:c.sent(),i.debug("channel changelog sync from",null===(a=this._metadata)||void 0===a?void 0:a.token),c.label=2;case 2:return c.trys.push([2,5,,8]),[4,rr.of(this._iid).getMyGroupChannelChangeLogs(null!==(u=null===(o=this._metadata)||void 0===o?void 0:o.token)&&void 0!==u?u:"",{includeEmpty:!0},ze.SYNC_CHANNEL_CHANGELOGS)];case 3:return t=c.sent(),n=t.hasMore,r=t.token,e.hasNext=n,e.nextToken=r,this._metadata&&(this._metadata.token=r),i.debug("channel changelog sync progress",e),[4,this.saveMetadata()];case 4:return c.sent(),[3,8];case 5:return s=c.sent(),i.debug("channel changelog sync error",s),s instanceof _&&s.isInvalidTokenError?[4,this.clearMetadata()]:[3,7];case 6:c.sent(),c.label=7;case 7:throw s;case 8:return[2,e]}}))}))})),this._connectionEventContext=o.on((function(e){if(e instanceof ee)if(e.stateType===te.CONNECTED)n.resume();else n.pause()}))}return e.of=function(t){return ds[t]||(ds[t]=new e({_iid:t})),ds[t].ref++,ds[t]},e.clear=function(e){ds[e]&&(ds[e].close(),delete ds[e])},e.prototype.loadMetadata=function(){return g(this,void 0,void 0,(function(){var e,t,n,r;return y(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 g(this,void 0,void 0,(function(){return y(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 g(this,void 0,void 0,(function(){return y(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=void 0,[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 ds[this._iid])},e}(),fs=function(){function e(e,t){var n=t.filter,r=t.order,s=t.limit,i=this;this.channels=[],this._iid=e,this._key="gcc-".concat(oe()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this.filter=null!=n?n:new Kt,this.order=null!=r?r:Ge.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=s?s:ye;var a=j.of(this._iid),o=a.sdkState,u=a.cacheContext,c=a.dispatcher;u.localCacheEnabled&&(this._backgroundSync=hs.of(e),this._backgroundSync.resume()),this._changelogSync=ps.of(e),this._changelogSync.resume(),rr.of(this._iid).subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){if(tt(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 ie({type:ae.FEATURE_LOCALCACHE,data:{use_local_cache:u.localCacheEnabled,collection_interface:{group_channel:!0}}})),c.on((function(e){e instanceof ee&&(e.stateType===te.CONNECTED?i._isGetRemoteChannelsSucceeded||g(i,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,this._revokeLoadMore()];case 1:return e.sent(),[2]}}))})):e.stateType===te.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=C(e),d=h.next();!d.done;d=h.next()){var p=d.value,f=vr(this.channels,p);f>=0&&this.channels.splice(f,1);var _=mr(this.channels,p,this.order).place;if(f<0)_===this.channels.length?!n&&this._hasMore||(u.push(p),this.channels.push(p)):(u.push(p),this.channels.splice(_,0,p));else switch(t){case ze.EVENT_CHANNEL_UPDATED:case ze.EVENT_MESSAGE_RECEIVED:case ze.SYNC_CHANNEL_CHANGELOGS:case ze.EVENT_MESSAGE_SENT:_!==f&&this._hasMore&&_===this.channels.length?l.push(p):(this.channels.splice(_,0,p),c.push(p));break;default:this.channels.splice(_,0,p),c.push(p)}}}catch(e){r={error:e}}finally{try{d&&!d.done&&(s=h.return)&&s.call(h)}finally{if(r)throw r.error}}if(l.length>0)try{for(var v=C(l),m=v.next();!m.done;m=v.next()){p=m.value;var E=vr(this.channels,p);-1!==E&&this.channels.splice(E,1)}}catch(e){i={error:e}}finally{try{m&&!m.done&&(a=v.return)&&a.call(v)}finally{if(i)throw i.error}}tt(t)&&Y((function(){return g(o,void 0,void 0,(function(){var e,n,r,s;return y(this,(function(i){return e=new ar(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=C(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 tt(t)&&i.length>0&&Y((function(){return g(s,void 0,void 0,(function(){var e,n;return y(this,(function(r){return e=new ar(t),(null===(n=this._handler)||void 0===n?void 0:n.onChannelsDeleted)&&this._handler.onChannelsDeleted(e,i),[2]}))}))})),i},e.prototype._getLocalChannels=function(){return g(this,void 0,void 0,(function(){var e,t;return y(this,(function(n){switch(n.label){case 0:return e=rr.of(this._iid),t=this.channels.length>0?function(e,t){var n,r,s,i;switch(t){case Ge.LATEST_LAST_MESSAGE:return null!==(r=null===(n=e.lastMessage)||void 0===n?void 0:n.createdAt)&&void 0!==r?r:e.createdAt;case Ge.CHRONOLOGICAL:return e.createdAt;case Ge.CHANNEL_NAME_ALPHABETICAL:return e.name;default:return null!==(i=null===(s=e.lastMessage)||void 0===s?void 0:s.createdAt)&&void 0!==i?i:e.createdAt}}(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:void 0)];case 1:return[2,n.sent()]}}))}))},e.prototype._getRemoteChannels=function(){return g(this,void 0,void 0,(function(){var e,t,n;return y(this,(function(r){switch(r.label){case 0:return[4,rr.of(this._iid).getMyGroupChannels(this._token,s(i(i({},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 g(this,void 0,void 0,(function(){var e;return y(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,ze.REQUEST_CHANNEL,!0),[3,4];case 3:return t.sent(),this._isGetRemoteChannelsSucceeded=!1,[3,4];case 4:return[2]}}))}))},e.prototype.loadMore=function(){return g(this,void 0,void 0,(function(){var e,t,n=this;return y(this,(function(r){switch(r.label){case 0:if(this._isDisposed)throw new _({code:X.COLLECTION_DISPOSED,message:"Collection has been disposed."});return this._hasMore?(e=j.of(this._iid).cacheContext,t=[],e.localCacheEnabled&&this._backgroundSync.completed?[4,S((function(){return g(n,void 0,void 0,(function(){return y(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,ze.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(),rr.of(this._iid).unsubscribeGroupChannelEvent(this._key))},e}(),_s=function(t){function n(e){var n=this,i=e.token,a=e.limit,o=e.order,u=e.includeEmpty,c=e.membershipFilter,l=e.channelNameContainsFilter,h=e.channelUrlsFilter,d=e.customTypesFilter,p=e.customTypeStartsWithFilter,f=e.superChannelFilter,_=e.metadataOrderKeyFilter,v=e.metadataKey,m=e.metadataValues,g=e.metadataValueStartsWith,y=e.includeFrozen,C=e.includeMetaData;return(n=t.call(this)||this).method=D.GET,n.path=O,n.params=r(s({token:i,limit:a,order:o,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:u,public_mode:xt.PUBLIC,public_membership_mode:c,name_contains:l,channel_urls:h,custom_types:d,custom_type_startswith:p,super_mode:f,metadata_order_key:_,metadata_key:v,metadata_values:m,metadata_value_startswith:g,show_frozen:y,show_metadata:C})),n}return e(n,t),n}(F),vs=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.channels=[];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 cs(e,t)}))),r.ts="number"==typeof a?a:0,r}return e(n,t),n}(R);!function(e){e.ALL="all",e.JOINED="joined"}(us||(us={}));var ms=function(t){function n(e,n){var r,s,i,a,o,u,c,l,h,d,p,f,_,v,m=this;return(m=t.call(this,e,n)||this).includeEmpty=!1,m.includeFrozen=!0,m.includeMetaData=!0,m.channelUrlsFilter=null,m.customTypesFilter=null,m.customTypeStartsWithFilter=null,m.channelNameContainsFilter=null,m.membershipFilter=us.ALL,m.superChannelFilter=Ht.ALL,m.metadataKey=null,m.metadataValues=null,m.metadataOrderKeyFilter=null,m.metadataValueStartsWith=null,m.order=ot.CHRONOLOGICAL,m.includeEmpty=null!==(r=n.includeEmpty)&&void 0!==r&&r,m.includeFrozen=null===(s=n.includeFrozen)||void 0===s||s,m.includeMetaData=null===(i=n.includeMetaData)||void 0===i||i,m.channelUrlsFilter=null!==(a=n.channelUrlsFilter)&&void 0!==a?a:null,m.customTypesFilter=null!==(o=n.customTypesFilter)&&void 0!==o?o:null,m.customTypeStartsWithFilter=null!==(u=n.customTypeStartsWithFilter)&&void 0!==u?u:null,m.channelNameContainsFilter=null!==(c=n.channelNameContainsFilter)&&void 0!==c?c:null,m.membershipFilter=null!==(l=n.membershipFilter)&&void 0!==l?l:us.ALL,m.superChannelFilter=null!==(h=n.superChannelFilter)&&void 0!==h?h:Ht.ALL,m.metadataKey=null!==(d=n.metadataKey)&&void 0!==d?d:null,m.metadataValues=null!==(p=n.metadataValues)&&void 0!==p?p:null,m.metadataOrderKeyFilter=null!==(f=n.metadataOrderKeyFilter)&&void 0!==f?f:null,m.metadataValueStartsWith=null!==(_=n.metadataValueStartsWith)&&void 0!==_?_:null,m.order=null!==(v=n.order)&&void 0!==v?v:ot.CHRONOLOGICAL,m}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&b("boolean",this.includeEmpty)&&b("boolean",this.includeFrozen)&&b("boolean",this.includeMetaData)&&b("string",this.channelNameContainsFilter,!0)&&E("string",this.channelUrlsFilter,!0)&&E("string",this.customTypesFilter,!0)&&b("string",this.customTypeStartsWithFilter,!0)&&a(us,this.membershipFilter)&&a(Ht,this.superChannelFilter)&&a(ot,this.order)&&b("string",this.metadataOrderKeyFilter,!0)&&b("string",this.metadataKey,!0)&&E("string",this.metadataValues,!0)&&b("string",this.metadataValueStartsWith,!0)},n.prototype.next=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,a,o,u,c;return y(this,(function(l){switch(l.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 _s(s(i(i({},this),{token:this._token}))),[4,n.send(r)]):[3,2]):[3,5];case 1:return a=l.sent(),o=a.as(vs),u=o.channels,c=o.token,this._token=c,this._hasNext=!!c,this._isLoading=!1,[2,u];case 2:return[2,e];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},n}(W),gs=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}(gt)),ys=function(t){function n(e){var n=this,i=e.token,a=e.limit,o=e.order,u=e.reverse,c=e.channelUrl,l=e.messageTypeFilter,h=e.scheduledStatus;return(n=t.call(this)||this).method=D.GET,n.path="".concat(H),n.params=r(s({token:i,limit:a,reverse:u,channel_url:c,order:o,message_type:l,status:h})),n}return e(n,t),n}(F),Cs=function(t){function n(e,n){var r=t.call(this,e,n)||this;r.scheduledMessages=[];var s=n.next,i=n.scheduled_messages;return r.token=s,r.scheduledMessages=i.map((function(t){return bt(e,t)})),r}return e(n,t),n}(R),Es=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=N.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:N.ALL,u}return e(n,t),n.prototype._validate=function(){return t.prototype._validate.call(this)&&b("string",this.channelUrl,!0)&&(a(ut,this.order)||null===this.order)&&b("boolean",this.reverse)&&(E(yt,this.scheduledStatus)||null===this.scheduledStatus)&&a(N,this.messageTypeFilter)},n.prototype.next=function(){return g(this,void 0,void 0,(function(){var e,t,n,r,a,o;return y(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 ys(s(i(i({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=u.sent(),r=n.as(Cs),a=r.scheduledMessages,o=r.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,a];case 2:return[2,[]];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},n}(W),bs=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 rr(e,{sdkState:r,cacheContext:c,dispatcher:s,sessionManager:i,requestQueue:a,logger:o})},n.prototype.createGroupChannelCollection=function(e){return void 0===e&&(e={}),new fs(this._iid,e)},n.prototype.createMyGroupChannelListQuery=function(e){return void 0===e&&(e={}),new $n(this._iid,e)},n.prototype.createPublicGroupChannelListQuery=function(e){return void 0===e&&(e={}),new ms(this._iid,e)},n.prototype.createScheduledMessageListQuery=function(e){return void 0===e&&(e={}),new Es(this._iid,e)},n.prototype.addGroupChannelHandler=function(e,t){f(b("string",e)&&t instanceof gs).throw(_.invalidParameters),this._manager.addHandler(e,t)},n.prototype.removeGroupChannelHandler=function(e){f(b("string",e)).throw(_.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 g(this,void 0,void 0,(function(){return y(this,(function(t){return f(b("string",e)).throw(_.invalidParameters),[2,this._manager.getChannel(e)]}))}))},n.prototype.getChannelWithoutCache=function(e){return g(this,void 0,void 0,(function(){return y(this,(function(t){return f(b("string",e)).throw(_.invalidParameters),[2,this._manager.getChannelWithoutCache(e)]}))}))},n.prototype.getMyGroupChannelChangeLogsByToken=function(e,t){return void 0===t&&(t={}),g(this,void 0,void 0,(function(){var n;return y(this,(function(r){switch(r.label){case 0:return n=i(i({},Zt),t),f(b("string",e)&&$t(n)).throw(_.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,r.sent()]}}))}))},n.prototype.getMyGroupChannelChangeLogsByTimestamp=function(e,t){return void 0===t&&(t={}),g(this,void 0,void 0,(function(){var n;return y(this,(function(r){switch(r.label){case 0:return n=i(i({},Zt),t),f(b("number",e)&&$t(n)).throw(_.invalidParameters),[4,this._manager.getMyGroupChannelChangeLogs(e,n)];case 1:return[2,r.sent()]}}))}))},n.prototype.getGroupChannelCount=function(e){return g(this,void 0,void 0,(function(){var t;return y(this,(function(n){return t=i(i({},en),e),f(tn(t)).throw(_.invalidParameters),[2,this._manager.getGroupChannelCount(t)]}))}))},n.prototype.getUnreadItemCount=function(e){return void 0===e&&(e={}),g(this,void 0,void 0,(function(){return y(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 g(this,void 0,void 0,(function(){return y(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={}),g(this,void 0,void 0,(function(){return y(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={}),g(this,void 0,void 0,(function(){return y(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={}),g(this,void 0,void 0,(function(){var t;return y(this,(function(n){return t=i(i({},Jt),e),f(Xt(t)).throw(_.invalidParameters),[2,this._manager.createChannel(t)]}))}))},n.prototype.createDistinctChannelIfNotExist=function(e){return void 0===e&&(e={}),g(this,void 0,void 0,(function(){var t;return y(this,(function(n){return t=i(i({},Jt),e),f(Xt(t)).throw(_.invalidParameters),t&&(t.isDistinct=!0),[2,this.createChannel(t)]}))}))},n.prototype.createChannelWithUserIds=function(e,t,n,r,s,a){return void 0===t&&(t=!1),void 0===s&&(s=""),void 0===a&&(a=""),g(this,void 0,void 0,(function(){var o;return y(this,(function(u){return o=i(i({},Jt),{invitedUserIds:e,isDistinct:t,name:n,data:s,customType:a}),"string"==typeof r?o.coverUrl=r:o.coverImage=r,[2,this.createChannel(o)]}))}))},n.prototype.markAsReadAll=function(){return g(this,void 0,void 0,(function(){return y(this,(function(e){return this._manager.markAsReadAll(),[2]}))}))},n.prototype.markAsReadWithChannelUrls=function(e){return g(this,void 0,void 0,(function(){return y(this,(function(t){return f(E("string",e)).throw(_.invalidParameters),this._manager.markAsReadWithChannelUrls(e),[2]}))}))},n.prototype.markAsDelivered=function(e){return g(this,void 0,void 0,(function(){return y(this,(function(t){switch(t.label){case 0:return f(b("string",e)).throw(_.invalidParameters),[4,this.getChannel(e)];case 1:return[4,t.sent().markAsDelivered()];case 2:return t.sent(),[2]}}))}))},n}(ve);export{ts as CountPreference,cs as GroupChannel,fs as GroupChannelCollection,ar as GroupChannelEventContext,Kt as GroupChannelFilter,gs as GroupChannelHandler,$n as GroupChannelListQuery,bs as GroupChannelModule,Wt as GroupChannelSearchField,Vt as HiddenChannelFilter,rs as HiddenState,zt as Member,Nr as MemberListOrder,Lr as MemberListQuery,Rt as MemberState,Sr as MemberStateFilter,us as MembershipFilter,Tr as MessageCollection,Ur as MessageCollectionInitHandler,sr as MessageCollectionInitPolicy,or as MessageEventContext,Mr as MutedMemberFilter,ns as MutedState,Ot as MyMemberStateFilter,qt as OperatorFilter,ss as PinnedMessage,os as PinnedMessageListQuery,xt as PublicChannelFilter,ms as PublicGroupChannelListQuery,Bt as QueryType,jt as ReadStatus,Es as ScheduledMessageListQuery,Ht as SuperChannelFilter,Gt as UnreadChannelFilter,Qt as UnreadItemKey}; diff --git a/index.js b/index.js index 2b84d22..0485e36 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,u as v,f as _,U as m,g as b,h as y,P as w,j as k,k as E,l as D,m as A,B as F,S as j,V as q,o as z,L as x,p as H,q as G,r as W,s as K,v as V,C as J,t as $,w as ee,x as te,y as ne,W as re,z as ie,D as se,F as oe,G as ae,H as ue,I as ce,J as de,K as le,M as he,N as fe,O as pe}from"./lib/__bundle-75942676.js";export{R as CachedChannelInfo,Q as ChannelType,C as ConnectionState,L as LocalCacheConfig,T as LogLevel,O as PushTemplate,I as PushTokenRegistrationState,P as PushTokenType,N as PushTriggerOption,X as Role,o as SendbirdChatOptions,S as SendbirdError,Y as UIKitConfigInfo,U as User,Z as UserOnlineState}from"./lib/__bundle-75942676.js";import{M as ve,a as _e}from"./lib/__bundle-84f74e8d.js";export{P as Plugin}from"./lib/__bundle-84f74e8d.js";import{PollModule as ge}from"./poll.js";import{N as me,a as be,b as ye,c as we,d as ke,e as Ie}from"./lib/__bundle-e875840b.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-e875840b.js";import{g as Se,G as Ce,a as Te,M as Pe,N as Ee,b as De,c as Ue,A as Oe,I as Le,d as Ne,U as Ae,e as Me,f as Re,D as Fe,h as je,i as qe,j as ze,R as Qe,k as xe}from"./lib/__bundle-fd51cf65.js";export{c as MemoryStore}from"./lib/__bundle-fd51cf65.js";import{P as He,a as Ge}from"./lib/__bundle-ad161b2c.js";export{P as Participant}from"./lib/__bundle-8fdac8b9.js";var We={profileImage:void 0,profileUrl:void 0,nickname:void 0},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.onSessionExpired=r,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=r,this.onSessionRefreshed=r,this.onSessionClosed=r})),Ve=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})),Be=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})),Je=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:me,keyName:be,index:[Se(Ce.LATEST_LAST_MESSAGE),Se(Ce.CHRONOLOGICAL),Se(Ce.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:ye,keyName:we,index:[Te(Pe.CHANNEL_LATEST),Te(Pe.NEWEST_CHILD_MESSAGE)]},{collectionName:Ee,keyName:De,index:[Te(Pe.CHANNEL_LATEST),Te(Pe.NEWEST_CHILD_MESSAGE)]},{collectionName:ke,keyName:Ie}])]}))}))})(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()}},Xe=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},Ye=function(e){function t(t){var n=t.getVisibilityState,r=void 0===n?Xe: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._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=void 0),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((function(){e._pauseDelayTimer=void 0,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),Ze=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}(),$e=function(e){function t(t){var n=t.userId,r=t.nickname,i=t.profileUrl,s=t.profileImage,o=t.preferredLanguages,a=e.call(this)||this;return a.method=d.PUT,a.path="".concat(l,"/").concat(encodeURIComponent(n)),a.params=p(v({nickname:r,profile_url:i,profile_file:s,preferred_languages:o})),a}return n(t,e),t}(_),et=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new m(t,b({},n)),r}return n(t,e),t}(y),tt=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}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?w[n.type.toLowerCase()]:w.UNKNOWN,r.user=new m(t,n.user),r}n(t,e)}(y);var nt=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}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?w[n.type.toLowerCase()]:w.UNKNOWN,r.user=new m(t,n.user),r}n(t,e)}(y);var rt=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}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new m(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(y);var it=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}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new m(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(y);var st=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}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?w[n.type.toLowerCase()]:w.UNKNOWN,r.user=new m(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(y);var ot=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}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?w[n.type.toLowerCase()]:w.UNKNOWN,r.user=new m(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(y);var at=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}(_),ut=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTokens={type:n.type?w[n.type.toLowerCase()]:w.UNKNOWN,deviceTokens:n.device_tokens,hasMore:n.has_more,token:n.token},r}return n(t,e),t}(y),ct=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}(_),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}(y),lt=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}(_),ht=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}(y),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(encodeURIComponent(n),"/push_preference"),r}return n(t,e),t}(_),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}(y),vt=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}(_),_t=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}(y),gt=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}(_),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}(y),bt=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}(_),yt=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}(y),wt=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}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new m(t,n),r}n(t,e)}(y);var kt=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}(_);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(y);var It=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}(_),St=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}(y),Ct=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}(_),Tt=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}(y),Pt=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}(_),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}(y),Dt=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}(_),Ut=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}(y),Ot=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}(_),Lt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.changelogs={addedUsers:n.added.map((function(e){return new m(t,e)})),updatedUsers:n.updated.map((function(e){return new m(t,e)})),deletedUserIds:n.deleted,hasMore:n.has_more,token:n.next},r}return n(t,e),t}(y),Nt=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}(_),At=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}(y),Mt=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}(_);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(y);var Rt=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}(_),Ft=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new m(t,e)})),r}return n(t,e),t}(y),jt=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}(_);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(y);var qt=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}(_),zt=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}(y),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}(_);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(y);var xt,Ht=function(e){this.key=e.key,this.url=e.url},Gt=function(e){this.id=e.id,this.name=e.name,this.url=e.url,this.emojis=e.emojis?e.emojis.map((function(e){return new Ht(e)})):[]},Wt=function(e){this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map((function(e){return new Gt(e)})):[]},Kt=function(e){function t(){var t=e.call(this)||this;return t.method=d.GET,t.path=k,t}return n(t,e),t}(_),Vt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiContainer=new Wt(n),r}return n(t,e),t}(y),Bt=function(e){function t(t){var n=t.categoryId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(k,"/").concat(n),r}return n(t,e),t}(_),Jt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiCategory=new Gt(n),r}return n(t,e),t}(y),Xt=function(e){function t(t){var n=t.key,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(E,"/").concat(n),r}return n(t,e),t}(_),Yt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emoji=new Ht(n),r}return n(t,e),t}(y),Zt=function(e){function t(){var t=e.call(this)||this;return t.method=d.GET,t.path="".concat(D),t}return n(t,e),t}(_),$t=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}(y),en=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}(_),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 m(t,e)})),r.next=n.next,r}return n(t,e),t}(y),nn=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)&&A("string",this.userIdsFilter,!0)&&t("string",this.metaDataKeyFilter,!0)&&A("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=q.of(this._iid).requestQueue,t=new en(v(b(b({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(tn),i=r.users,s=r.next,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw j.queryInProgress;case 4:return[3,6];case 5:throw j.invalidParameters;case 6:return[2]}}))}))},r}(F),rn=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}(_),sn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new m(t,e)})),r.next=n.next,r}return n(t,e),t}(y),on=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)&&A("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=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new rn(v(b(b({},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.next,this._token=u,this._hasNext=!!u,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw j.queryInProgress;case 4:return[3,6];case 5:throw j.invalidParameters;case 6:return[2]}}))}))},t}(F),an=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}(_),un=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.hasMore=n.has_more,r.users=n.users.map((function(e){return new m(t,e)})),r.next=n.next,r}return n(t,e),t}(y),cn=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=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new an(b(b({},this),{userId:t.userId,token:this._token})),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=a.sent(),s=i.as(un),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 j.queryInProgress;case 4:return[3,6];case 5:throw j.invalidParameters;case 6:return[2]}}))}))},t}(F),dn=function(){function n(e,t,n){var r=this;this._storeInitialized=!1,this._iid=e,this.options=t;var i=q.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 Ze({logger:h,connectionDelegate:{reconnect:function(){var t=q.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(){q.of(e).connectionManager.disconnect()}}});var v=new Ne(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 Ye({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 te){if(t.stateType===ne.CONNECTED)v.processNonAutoResendRegisteredPendingMessages()}else if(t instanceof re){if("USEV"===t.code){var n=t.as(Ae).event;if(n.category===Me.FRIEND_DISCOVERED){var i=Re.getDataAsFriendDiscoveredEvent(e,n).friendDiscoveries;ie((function(){return s(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onFriendsDiscovered&&e.onFriendsDiscovered(i)}))]}))}))}))}}}else if(t instanceof se){var c=q.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&&ie((function(){return s(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(c.all,c.customTypes)}))]}))}))}))}else t instanceof oe?u.preference.set(r._getUserProfileCacheKey(o.userId),ae.payloadify(t.userProfile)):t instanceof ue&&t.error&&t.error.isSessionRevokedError&&(h.debug("session revoked."),r.disconnect())}))}return n.init=function(e){var t=e.appId,r=e.appVersion,i=e.modules,s=void 0===i?[]:i,o=e.options,a=void 0===o?new z:o,u=e.debugMode,c=void 0!==u&&u,d=e.customApiHost,l=e.customWebSocketHost,h=e.newInstance,f=void 0!==h&&h,p=e.logLevel,v=e.localCacheEnabled,_=void 0!==v&&v,g=e.localCacheConfig,m=void 0===g?new x:g,b=e.localCacheEncryption,y=e.useAsyncStorageStore,w=void 0===y?null:y,k=e.appStateToggleEnabled,I=void 0===k||k;if(!xt||f){var S="su-".concat(H()),C=null!=b?b:{encrypt:function(e){return e},decrypt:function(e){return e}},T=new Ue({encryption:C});c||(T=G()?w?new Oe({AsyncStorage:w,encryption:C}):new Ue({encryption:C}):new Le({encryption:C})),new q(S,{appId:t,appVersion:r,options:a,apiHost:null!=d?d:"https://api-".concat(t,".sendbird.com"),websocketHost:null!=l?l:"wss://ws-".concat(t,".sendbird.com"),store:T,encryption:C,logLevel:p,localCacheEnabled:_,localCacheConfig:m,debugMode:c,appStateToggleEnabled:I});var P=[new ve,new ge],E=new n(S,a,W(W([],K(s),!1),K(P),!1));return xt||(xt=E),E}return xt},Object.defineProperty(n,"instance",{get:function(){return xt},enumerable:!1,configurable:!0}),Object.defineProperty(n,"version",{get:function(){return V},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appId",{get:function(){return q.of(this._iid).sdkState.appId},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appInfo",{get:function(){var e=q.of(this._iid).appInfo;return null!=e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appVersion",{get:function(){var e;return null!==(e=q.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"debugMode",{get:function(){return!!q.of(this._iid).debugMode},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"logLevel",{get:function(){return q.of(this._iid).logger.level},set:function(e){q.of(this._iid).logger.level=e},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isCacheEnabled",{get:function(){return q.of(this._iid).cacheContext.localCacheEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheConfig",{get:function(){var e=q.of(this._iid).cacheContext;return e.localCacheEnabled?e.localCacheConfig:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"ekey",{get:function(){return q.of(this._iid).sessionManager.ekey},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"currentUser",{get:function(){var e;return null!==(e=q.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){var e=q.of(this._iid).connectionManager;return e.isConnected?J.OPEN:e.isConnecting?J.CONNECTING:J.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"lastConnectedAt",{get:function(){var e=q.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"fcmPushToken",{get:function(){var e;return null!==(e=this._fcmPushToken)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"apnsPushToken",{get:function(){var e;return null!==(e=this._apnsPushToken)&&void 0!==e?e:null},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=q.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof Ue?n.store:null;throw j.debugModeRequired},n.prototype.addExtension=function(e,t){var n=q.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&n.extensions&&(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=q.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.replaceStore(new Ue),[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=q.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!==xe.CLOSED&&r.nestdb.name===u?[3,4]:((c=r.nestdb=new je({name:"sendbird@".concat(n.appId,"/").concat(e,".db"),version:2,store:r.store})).on("upgrade",Je(c,r.store)),c.on("storeReplaced",(function(e){r.replaceStore(e),r.localCacheEnabled=!1,c.on("upgrade",Je(c,r.store))})),[4,c.open()]);case 3:a.sent(),this._storeInitialized=!0,s.dispatch(new Fe(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,j.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=q.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=q.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 $(A("string",e)).throw(j.invalidParameters),t=qe.of(this._iid),n=ze.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 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:$(t("string",e)&&t("string",n,!0)).throw(j.invalidParameters),r=q.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(),q.of(this._iid).dispatcher.dispatch(new Qe),[3,4];case 3:return a.sent(),c=q.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 ae(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=q.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=q.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=q.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=q.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=q.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){$(e instanceof Ke).throw(j.invalidParameters),q.of(this._iid).sessionManager.handler=e},n.prototype.addUserEventHandler=function(e,n){$(t("string",e)&&n instanceof Be).throw(j.invalidParameters),q.of(this._iid).userEventHandlers.set(e,n)},n.prototype.removeUserEventHandler=function(e){q.of(this._iid).userEventHandlers.delete(e)},n.prototype.removeAllUserEventHandler=function(){q.of(this._iid).userEventHandlers.clear()},n.prototype.addConnectionHandler=function(e,n){$(t("string",e)&&n instanceof Ve).throw(j.invalidParameters),q.of(this._iid).connectionHandlers.set(e,n)},n.prototype.removeConnectionHandler=function(e){q.of(this._iid).connectionHandlers.delete(e)},n.prototype.removeAllConnectionHandler=function(){q.of(this._iid).connectionHandlers.clear()},n.prototype.createApplicationUserListQuery=function(e){return void 0===e&&(e={}),new nn(this._iid,e)},n.prototype.createBlockedUserListQuery=function(e){return void 0===e&&(e={}),new on(this._iid,e)},n.prototype.createFriendListQuery=function(e){return void 0===e&&(e={}),new cn(this._iid,e)},n.prototype.createMessageSearchQuery=function(e){return new _e(this._iid,e)},n.prototype.createPollListQuery=function(e){return new He(this._iid,b({},e))},n.prototype.createPollVoterListQuery=function(e){return new Ge(this._iid,b({},e))},n.prototype.buildUserFromSerializedData=function(e){var t=ee(e);return new m(this._iid,m.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=b(b({},We),n),$(function(n){return e(n.profileImage,!0)&&t("string",n.profileUrl,!0)&&t("string",n.nickname,!0)}(r)).throw(j.invalidParameters),this.currentUser?(i=q.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new $e(b({userId:s.userId},r)),[4,o.send(u)]):[3,2];case 1:return c=a.sent(),d=c.as(et).user,this.currentUser&&(r.nickname&&(this.currentUser.nickname=d.nickname),(r.profileUrl||r.profileImage)&&(this.currentUser.plainProfileUrl=d.profileUrl)),[2,d];case 2:throw j.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 $(A("string",e)).throw(j.invalidParameters),this.currentUser?(t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new $e({userId:n.userId,preferredLanguages:e}),[4,r.send(i)]):[3,2];case 1:return s=a.sent(),o=s.as(et).user,this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),[2,o];case 2:throw j.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($(t("string",e)).throw(j.invalidParameters),!this.currentUser)return[3,6];d.label=1;case 1:return d.trys.push([1,4,,5]),n=q.of(this._iid),r=n.sessionManager,i=n.sdkState,o=n.requestQueue,r.hasDeviceToken(w.FCM,e)?[2,ce.SUCCESS]:(u=new nt({userId:i.userId,token:e}),[4,o.send(u)]);case 2:return d.sent(),[4,de((function(){return s(c,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.setDeviceToken(w.FCM,e),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return d.sent(),this._fcmPushToken="",[2,ce.SUCCESS];case 4:return d.sent(),[2,ce.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,ce.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($(t("string",e)).throw(j.invalidParameters),!this.currentUser)return[3,6];l.label=1;case 1:return l.trys.push([1,4,,5]),n=q.of(this._iid),r=n.sessionManager,i=n.sdkState,o=n.requestQueue,u=new it({userId:i.userId,token:e}),[4,o.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,de((function(){return s(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(w.FCM,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._fcmPushToken="",[2,ce.SUCCESS];case 4:return l.sent(),[2,ce.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,ce.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=q.of(this._iid),t=e.sessionManager,n=e.sdkState,r=e.requestQueue,i=new ot({userId:n.userId}),[4,r.send(i)]):[3,3];case 1:return o=c.sent().lastDeletedAt,[4,de((function(){return s(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(w.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($(t("string",e)).throw(j.invalidParameters),!this.currentUser)return[3,6];d.label=1;case 1:return d.trys.push([1,4,,5]),n=q.of(this._iid),r=n.sessionManager,i=n.sdkState,o=n.requestQueue,r.hasDeviceToken(w.APNS,e)?[2,ce.SUCCESS]:(u=new tt({userId:i.userId,token:e}),[4,o.send(u)]);case 2:return d.sent(),[4,de((function(){return s(c,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.setDeviceToken(w.APNS,e),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return d.sent(),this._apnsPushToken="",[2,ce.SUCCESS];case 4:return d.sent(),[2,ce.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,ce.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($(t("string",e)).throw(j.invalidParameters),!this.currentUser)return[3,6];l.label=1;case 1:return l.trys.push([1,4,,5]),n=q.of(this._iid),r=n.sessionManager,i=n.sdkState,o=n.requestQueue,u=new rt({userId:i.userId,token:e}),[4,o.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,de((function(){return s(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(w.APNS,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._apnsPushToken="",[2,ce.SUCCESS];case 4:return l.sent(),[2,ce.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,ce.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=q.of(this._iid),t=e.sessionManager,n=e.sdkState,r=e.requestQueue,i=new st({userId:n.userId}),[4,r.send(i)]):[3,3];case 1:return o=c.sent().lastDeletedAt,[4,de((function(){return s(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(w.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=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new ct({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,{autoAccept:i.as(dt).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 $(t("boolean",e)).throw(j.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new lt({userId:r.userId,willAutoAccept:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,{autoAccept:o.as(ht).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=q.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(pt).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 $(t("boolean",e)&&t("number",n)&&t("number",r)&&t("number",i)&&t("number",o)&&t("string",u)).throw(j.invalidParameters),s=q.of(this._iid),c=s.sdkState,d=s.requestQueue,l=new vt({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(_t).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=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new gt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(mt).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 $(t("boolean",e)&&t("number",n)&&t("number",r)).throw(j.invalidParameters),i=q.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new bt({userId:s.userId,snoozeOn:e,startTs:n,endTs:r}),[4,o.send(u)];case 1:return c=a.sent(),[2,c.as(yt).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 $(t("string",e)&&he(w,n)).throw(j.invalidParameters),r=q.of(this._iid),i=r.sdkState,s=r.requestQueue,o=r.sessionManager,u=new at({userId:i.userId,type:n,token:e}),[4,s.send(u)];case 1:c=a.sent(),d=c.as(ut).pushTokens;try{for(l=le(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=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new It({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(St).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 $(he(fe,e)).throw(j.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Ct({userId:n.userId,pushTriggerOption:e}),[4,r.send(i)];case 1:return[2,s.sent().as(Tt).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=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Pt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(Et).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 $(he(pe,e)).throw(j.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Dt({userId:n.userId,templateName:e}),[4,r.send(i)];case 1:return[2,s.sent().as(Ut).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 $(e instanceof m||t("string",e)).throw(j.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new wt({userId:r.userId,blockedUserId:e instanceof m?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.blockUserWithUserId=function(e){return 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 $(e instanceof m||t("string",e)).throw(j.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new kt({userId:r.userId,unblockedUserId:e instanceof m?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.unblockUserWithUserId=function(e){return 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 $(t("string",e)).throw(j.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Ot({userId:r.userId,token:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,o.as(Lt).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=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new qt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(zt).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 $(t("boolean",e)).throw(j.invalidParameters),n=q.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=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Nt({userId:n.userId,discoveries:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(At).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 $(A("string",e)).throw(j.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Mt({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 $(A("string",e)).throw(j.invalidParameters),t=q.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=o.sent(),[2,s.as(Ft).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 $(A("string",e)).throw(j.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new jt({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=q.of(this._iid).requestQueue,t=new Kt,[4,e.send(t)];case 1:return n=r.sent(),[2,n.as(Vt).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=q.of(this._iid).requestQueue,n=new Bt({categoryId:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Jt).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=q.of(this._iid).requestQueue,n=new Xt({key:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Yt).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=q.of(this._iid),$(e.hasExtension("sb_uikit")).throw(j.notSupportedError),t=e.requestQueue,n=new Zt,[4,t.send(n)];case 1:return r=i.sent(),[2,r.as($t).uikitConfiguration]}}))}))},n}();export{nn as ApplicationUserListQuery,on as BlockedUserListQuery,Ve as ConnectionHandler,Ht as Emoji,Gt as EmojiCategory,Wt as EmojiContainer,cn as FriendListQuery,Ke as SessionHandler,Be as UserEventHandler,dn 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,u as v,f as _,U as m,g as y,h as b,P as w,j as k,k as E,l as D,m as A,B as F,S as j,V as q,o as z,L as x,p as H,q as G,r as W,s as K,v as V,C as J,t as $,w as ee,x as te,y as ne,W as re,z as ie,D as se,F as oe,G as ae,H as ue,I as ce,J as de,K as le,M as he,N as fe,O as pe}from"./lib/__bundle-087816c3.js";export{R as CachedChannelInfo,Q as ChannelType,C as ConnectionState,L as LocalCacheConfig,T as LogLevel,O as PushTemplate,I as PushTokenRegistrationState,P as PushTokenType,N as PushTriggerOption,X as Role,o as SendbirdChatOptions,S as SendbirdError,Y as UIKitConfigInfo,U as User,Z as UserOnlineState}from"./lib/__bundle-087816c3.js";import{M as ve,a as _e}from"./lib/__bundle-80fd264e.js";export{P as Plugin}from"./lib/__bundle-80fd264e.js";import{PollModule as ge}from"./poll.js";import{N as me,a as ye,b as be,c as we,d as ke,e as Ie}from"./lib/__bundle-50274a15.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-50274a15.js";import{g as Se,G as Ce,a as Te,M as Pe,N as Ee,b as De,c as Ue,A as Oe,I as Le,d as Ne,U as Ae,e as Me,f as Re,D as Fe,h as je,i as qe,j as ze,R as Qe,k as xe}from"./lib/__bundle-1ef675e5.js";export{c as MemoryStore}from"./lib/__bundle-1ef675e5.js";import{P as He,a as Ge}from"./lib/__bundle-8f39cad4.js";export{P as Participant}from"./lib/__bundle-cd6df760.js";var We={profileImage:void 0,profileUrl:void 0,nickname:void 0},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.onSessionExpired=r,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=r,this.onSessionRefreshed=r,this.onSessionClosed=r})),Ve=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})),Be=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})),Je=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:me,keyName:ye,index:[Se(Ce.LATEST_LAST_MESSAGE),Se(Ce.CHRONOLOGICAL),Se(Ce.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:be,keyName:we,index:[Te(Pe.CHANNEL_LATEST),Te(Pe.NEWEST_CHILD_MESSAGE)]},{collectionName:Ee,keyName:De,index:[Te(Pe.CHANNEL_LATEST),Te(Pe.NEWEST_CHILD_MESSAGE)]},{collectionName:ke,keyName:Ie}])]}))}))})(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()}},Xe=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},Ye=function(e){function t(t){var n=t.getVisibilityState,r=void 0===n?Xe: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._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=void 0),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((function(){e._pauseDelayTimer=void 0,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),Ze=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}(),$e=function(e){function t(t){var n=t.userId,r=t.nickname,i=t.profileUrl,s=t.profileImage,o=t.preferredLanguages,a=e.call(this)||this;return a.method=d.PUT,a.path="".concat(l,"/").concat(encodeURIComponent(n)),a.params=p(v({nickname:r,profile_url:i,profile_file:s,preferred_languages:o})),a}return n(t,e),t}(_),et=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new m(t,y({},n)),r}return n(t,e),t}(b),tt=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}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?w[n.type.toLowerCase()]:w.UNKNOWN,r.user=new m(t,n.user),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.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}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.type=n.type?w[n.type.toLowerCase()]:w.UNKNOWN,r.user=new m(t,n.user),r}n(t,e)}(b);var rt=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}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new m(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(b);var it=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}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.token=n.token,r.user=new m(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(b);var st=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}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?w[n.type.toLowerCase()]:w.UNKNOWN,r.user=new m(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(b);var ot=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}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.type=n.type?w[n.type.toLowerCase()]:w.UNKNOWN,r.user=new m(t,n.user),r.lastDeletedAt=n.device_token_last_deleted_at,r}n(t,e)}(b);var at=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}(_),ut=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.pushTokens={type:n.type?w[n.type.toLowerCase()]:w.UNKNOWN,deviceTokens:n.device_tokens,hasMore:n.has_more,token:n.token},r}return n(t,e),t}(b),ct=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}(_),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=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}(_),ht=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),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(encodeURIComponent(n),"/push_preference"),r}return n(t,e),t}(_),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=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}(_),_t=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),gt=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}(_),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),yt=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}(_),bt=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),wt=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}(_);!function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.user=new m(t,n),r}n(t,e)}(b);var kt=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}(_);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(b);var It=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}(_),St=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),Ct=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}(_),Tt=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),Pt=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}(_),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.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}(_),Ut=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),Ot=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}(_),Lt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.changelogs={addedUsers:n.added.map((function(e){return new m(t,e)})),updatedUsers:n.updated.map((function(e){return new m(t,e)})),deletedUserIds:n.deleted,hasMore:n.has_more,token:n.next},r}return n(t,e),t}(b),Nt=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}(_),At=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),Mt=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}(_);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(b);var Rt=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}(_),Ft=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new m(t,e)})),r}return n(t,e),t}(b),jt=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}(_);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(b);var qt=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}(_),zt=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}(_);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e)}(b);var xt,Ht=function(e){this.key=e.key,this.url=e.url},Gt=function(e){this.id=e.id,this.name=e.name,this.url=e.url,this.emojis=e.emojis?e.emojis.map((function(e){return new Ht(e)})):[]},Wt=function(e){this.emojiHash=e.emoji_hash||"",this.emojiCategories=e.emoji_categories?e.emoji_categories.map((function(e){return new Gt(e)})):[]},Kt=function(e){function t(){var t=e.call(this)||this;return t.method=d.GET,t.path=k,t}return n(t,e),t}(_),Vt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiContainer=new Wt(n),r}return n(t,e),t}(b),Bt=function(e){function t(t){var n=t.categoryId,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(k,"/").concat(n),r}return n(t,e),t}(_),Jt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emojiCategory=new Gt(n),r}return n(t,e),t}(b),Xt=function(e){function t(t){var n=t.key,r=e.call(this)||this;return r.method=d.GET,r.path="".concat(E,"/").concat(n),r}return n(t,e),t}(_),Yt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.emoji=new Ht(n),r}return n(t,e),t}(b),Zt=function(e){function t(){var t=e.call(this)||this;return t.method=d.GET,t.path="".concat(D),t}return n(t,e),t}(_),$t=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),en=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}(_),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 m(t,e)})),r.next=n.next,r}return n(t,e),t}(b),nn=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)&&A("string",this.userIdsFilter,!0)&&t("string",this.metaDataKeyFilter,!0)&&A("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=q.of(this._iid).requestQueue,t=new en(v(y(y({},this),{token:this._token}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(tn),i=r.users,s=r.next,this._token=s,this._hasNext=!!s,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw j.queryInProgress;case 4:return[3,6];case 5:throw j.invalidParameters;case 6:return[2]}}))}))},r}(F),rn=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}(_),sn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.users=n.users.map((function(e){return new m(t,e)})),r.next=n.next,r}return n(t,e),t}(b),on=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)&&A("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=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new rn(v(y(y({},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.next,this._token=u,this._hasNext=!!u,this._isLoading=!1,[2,o];case 2:return[2,[]];case 3:throw j.queryInProgress;case 4:return[3,6];case 5:throw j.invalidParameters;case 6:return[2]}}))}))},t}(F),an=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}(_),un=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.hasMore=n.has_more,r.users=n.users.map((function(e){return new m(t,e)})),r.next=n.next,r}return n(t,e),t}(b),cn=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=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new an(y(y({},this),{userId:t.userId,token:this._token})),[4,n.send(r)]):[3,2]:[3,5];case 1:return i=a.sent(),s=i.as(un),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 j.queryInProgress;case 4:return[3,6];case 5:throw j.invalidParameters;case 6:return[2]}}))}))},t}(F),dn=function(){function n(e,t,n){var r=this;this._storeInitialized=!1,this._iid=e,this.options=t;var i=q.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 Ze({logger:h,connectionDelegate:{reconnect:function(){var t=q.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(){q.of(e).connectionManager.disconnect()}}});var v=new Ne(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 Ye({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 te){if(t.stateType===ne.CONNECTED)v.processNonAutoResendRegisteredPendingMessages()}else if(t instanceof re){if("USEV"===t.code){var n=t.as(Ae).event;if(n.category===Me.FRIEND_DISCOVERED){var i=Re.getDataAsFriendDiscoveredEvent(e,n).friendDiscoveries;ie((function(){return s(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onFriendsDiscovered&&e.onFriendsDiscovered(i)}))]}))}))}))}}}else if(t instanceof se){var c=q.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&&ie((function(){return s(r,void 0,void 0,(function(){return a(this,(function(e){return[2,f.forEach((function(e){e.onTotalUnreadMessageCountUpdated&&e.onTotalUnreadMessageCountUpdated(c.all,c.customTypes)}))]}))}))}))}else t instanceof oe?u.preference.set(r._getUserProfileCacheKey(o.userId),ae.payloadify(t.userProfile)):t instanceof ue&&t.error&&t.error.isSessionRevokedError&&(h.debug("session revoked."),r.disconnect())}))}return n.init=function(e){var t=e.appId,r=e.appVersion,i=e.modules,s=void 0===i?[]:i,o=e.options,a=void 0===o?new z:o,u=e.debugMode,c=void 0!==u&&u,d=e.customApiHost,l=e.customWebSocketHost,h=e.newInstance,f=void 0!==h&&h,p=e.logLevel,v=e.localCacheEnabled,_=void 0!==v&&v,g=e.localCacheConfig,m=void 0===g?new x:g,y=e.localCacheEncryption,b=e.useAsyncStorageStore,w=void 0===b?null:b,k=e.appStateToggleEnabled,I=void 0===k||k;if(!xt||f){var S="su-".concat(H()),C=null!=y?y:{encrypt:function(e){return e},decrypt:function(e){return e}},T=new Ue({encryption:C});c||(T=G()?w?new Oe({AsyncStorage:w,encryption:C}):new Ue({encryption:C}):new Le({encryption:C})),new q(S,{appId:t,appVersion:r,options:a,apiHost:null!=d?d:"https://api-".concat(t,".sendbird.com"),websocketHost:null!=l?l:"wss://ws-".concat(t,".sendbird.com"),store:T,encryption:C,logLevel:p,localCacheEnabled:_,localCacheConfig:m,debugMode:c,appStateToggleEnabled:I});var P=[new ve,new ge],E=new n(S,a,W(W([],K(s),!1),K(P),!1));return xt||(xt=E),E}return xt},Object.defineProperty(n,"instance",{get:function(){return xt},enumerable:!1,configurable:!0}),Object.defineProperty(n,"version",{get:function(){return V},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appId",{get:function(){return q.of(this._iid).sdkState.appId},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appInfo",{get:function(){var e=q.of(this._iid).appInfo;return null!=e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"appVersion",{get:function(){var e;return null!==(e=q.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"debugMode",{get:function(){return!!q.of(this._iid).debugMode},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"logLevel",{get:function(){return q.of(this._iid).logger.level},set:function(e){q.of(this._iid).logger.level=e},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isCacheEnabled",{get:function(){return q.of(this._iid).cacheContext.localCacheEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"localCacheConfig",{get:function(){var e=q.of(this._iid).cacheContext;return e.localCacheEnabled?e.localCacheConfig:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"ekey",{get:function(){return q.of(this._iid).sessionManager.ekey},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"currentUser",{get:function(){var e;return null!==(e=q.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){var e=q.of(this._iid).connectionManager;return e.isConnected?J.OPEN:e.isConnecting?J.CONNECTING:J.CLOSED},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"lastConnectedAt",{get:function(){var e=q.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"fcmPushToken",{get:function(){var e;return null!==(e=this._fcmPushToken)&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"apnsPushToken",{get:function(){var e;return null!==(e=this._apnsPushToken)&&void 0!==e?e:null},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=q.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof Ue?n.store:null;throw j.debugModeRequired},n.prototype.addExtension=function(e,t){var n=q.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&n.extensions&&(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=q.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.replaceStore(new Ue),[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=q.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!==xe.CLOSED&&r.nestdb.name===u?[3,4]:((c=r.nestdb=new je({name:"sendbird@".concat(n.appId,"/").concat(e,".db"),version:2,store:r.store})).on("upgrade",Je(c,r.store)),c.on("storeReplaced",(function(e){r.replaceStore(e),r.localCacheEnabled=!1,c.on("upgrade",Je(c,r.store))})),[4,c.open()]);case 3:a.sent(),this._storeInitialized=!0,s.dispatch(new Fe(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,j.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=q.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=q.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 $(A("string",e)).throw(j.invalidParameters),t=qe.of(this._iid),n=ze.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 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:$(t("string",e)&&t("string",n,!0)).throw(j.invalidParameters),r=q.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(),q.of(this._iid).dispatcher.dispatch(new Qe),[3,4];case 3:return a.sent(),c=q.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 ae(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=q.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=q.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=q.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=q.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=q.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){$(e instanceof Ke).throw(j.invalidParameters),q.of(this._iid).sessionManager.handler=e},n.prototype.addUserEventHandler=function(e,n){$(t("string",e)&&n instanceof Be).throw(j.invalidParameters),q.of(this._iid).userEventHandlers.set(e,n)},n.prototype.removeUserEventHandler=function(e){q.of(this._iid).userEventHandlers.delete(e)},n.prototype.removeAllUserEventHandler=function(){q.of(this._iid).userEventHandlers.clear()},n.prototype.addConnectionHandler=function(e,n){$(t("string",e)&&n instanceof Ve).throw(j.invalidParameters),q.of(this._iid).connectionHandlers.set(e,n)},n.prototype.removeConnectionHandler=function(e){q.of(this._iid).connectionHandlers.delete(e)},n.prototype.removeAllConnectionHandler=function(){q.of(this._iid).connectionHandlers.clear()},n.prototype.createApplicationUserListQuery=function(e){return void 0===e&&(e={}),new nn(this._iid,e)},n.prototype.createBlockedUserListQuery=function(e){return void 0===e&&(e={}),new on(this._iid,e)},n.prototype.createFriendListQuery=function(e){return void 0===e&&(e={}),new cn(this._iid,e)},n.prototype.createMessageSearchQuery=function(e){return new _e(this._iid,e)},n.prototype.createPollListQuery=function(e){return new He(this._iid,y({},e))},n.prototype.createPollVoterListQuery=function(e){return new Ge(this._iid,y({},e))},n.prototype.buildUserFromSerializedData=function(e){var t=ee(e);return new m(this._iid,m.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=y(y({},We),n),$(function(n){return e(n.profileImage,!0)&&t("string",n.profileUrl,!0)&&t("string",n.nickname,!0)}(r)).throw(j.invalidParameters),this.currentUser?(i=q.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new $e(y({userId:s.userId},r)),[4,o.send(u)]):[3,2];case 1:return c=a.sent(),d=c.as(et).user,this.currentUser&&(r.nickname&&(this.currentUser.nickname=d.nickname),(r.profileUrl||r.profileImage)&&(this.currentUser.plainProfileUrl=d.profileUrl)),[2,d];case 2:throw j.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 $(A("string",e)).throw(j.invalidParameters),this.currentUser?(t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new $e({userId:n.userId,preferredLanguages:e}),[4,r.send(i)]):[3,2];case 1:return s=a.sent(),o=s.as(et).user,this.currentUser&&(this.currentUser.preferredLanguages=o.preferredLanguages),[2,o];case 2:throw j.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($(t("string",e)).throw(j.invalidParameters),!this.currentUser)return[3,6];d.label=1;case 1:return d.trys.push([1,4,,5]),n=q.of(this._iid),r=n.sessionManager,i=n.sdkState,o=n.requestQueue,r.hasDeviceToken(w.FCM,e)?[2,ce.SUCCESS]:(u=new nt({userId:i.userId,token:e}),[4,o.send(u)]);case 2:return d.sent(),[4,de((function(){return s(c,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.setDeviceToken(w.FCM,e),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return d.sent(),this._fcmPushToken="",[2,ce.SUCCESS];case 4:return d.sent(),[2,ce.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,ce.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($(t("string",e)).throw(j.invalidParameters),!this.currentUser)return[3,6];l.label=1;case 1:return l.trys.push([1,4,,5]),n=q.of(this._iid),r=n.sessionManager,i=n.sdkState,o=n.requestQueue,u=new it({userId:i.userId,token:e}),[4,o.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,de((function(){return s(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(w.FCM,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._fcmPushToken="",[2,ce.SUCCESS];case 4:return l.sent(),[2,ce.ERROR];case 5:return[3,7];case 6:return this._fcmPushToken=e,[2,ce.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=q.of(this._iid),t=e.sessionManager,n=e.sdkState,r=e.requestQueue,i=new ot({userId:n.userId}),[4,r.send(i)]):[3,3];case 1:return o=c.sent().lastDeletedAt,[4,de((function(){return s(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(w.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($(t("string",e)).throw(j.invalidParameters),!this.currentUser)return[3,6];d.label=1;case 1:return d.trys.push([1,4,,5]),n=q.of(this._iid),r=n.sessionManager,i=n.sdkState,o=n.requestQueue,r.hasDeviceToken(w.APNS,e)?[2,ce.SUCCESS]:(u=new tt({userId:i.userId,token:e}),[4,o.send(u)]);case 2:return d.sent(),[4,de((function(){return s(c,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.setDeviceToken(w.APNS,e),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return d.sent(),this._apnsPushToken="",[2,ce.SUCCESS];case 4:return d.sent(),[2,ce.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,ce.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($(t("string",e)).throw(j.invalidParameters),!this.currentUser)return[3,6];l.label=1;case 1:return l.trys.push([1,4,,5]),n=q.of(this._iid),r=n.sessionManager,i=n.sdkState,o=n.requestQueue,u=new rt({userId:i.userId,token:e}),[4,o.send(u)];case 2:return c=l.sent().lastDeletedAt,[4,de((function(){return s(d,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return r.unsetDeviceToken(w.APNS,e),r.setDeviceTokenDeletedAt(c),[4,r.saveDeviceToken()];case 1:return t.sent(),[2]}}))}))}))];case 3:return l.sent(),this._apnsPushToken="",[2,ce.SUCCESS];case 4:return l.sent(),[2,ce.ERROR];case 5:return[3,7];case 6:return this._apnsPushToken=e,[2,ce.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=q.of(this._iid),t=e.sessionManager,n=e.sdkState,r=e.requestQueue,i=new st({userId:n.userId}),[4,r.send(i)]):[3,3];case 1:return o=c.sent().lastDeletedAt,[4,de((function(){return s(u,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return t.unsetDeviceTokens(w.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=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new ct({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,{autoAccept:i.as(dt).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 $(t("boolean",e)).throw(j.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new lt({userId:r.userId,willAutoAccept:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,{autoAccept:o.as(ht).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=q.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(pt).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 $(t("boolean",e)&&t("number",n)&&t("number",r)&&t("number",i)&&t("number",o)&&t("string",u)).throw(j.invalidParameters),s=q.of(this._iid),c=s.sdkState,d=s.requestQueue,l=new vt({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(_t).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=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new gt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(mt).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 $(t("boolean",e)&&t("number",n)&&t("number",r)).throw(j.invalidParameters),i=q.of(this._iid),s=i.sdkState,o=i.requestQueue,u=new yt({userId:s.userId,snoozeOn:e,startTs:n,endTs:r}),[4,o.send(u)];case 1:return c=a.sent(),[2,c.as(bt).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 $(t("string",e)&&he(w,n)).throw(j.invalidParameters),r=q.of(this._iid),i=r.sdkState,s=r.requestQueue,o=r.sessionManager,u=new at({userId:i.userId,type:n,token:e}),[4,s.send(u)];case 1:c=a.sent(),d=c.as(ut).pushTokens;try{for(l=le(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=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new It({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(St).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 $(he(fe,e)).throw(j.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Ct({userId:n.userId,pushTriggerOption:e}),[4,r.send(i)];case 1:return[2,s.sent().as(Tt).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=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Pt({userId:t.userId}),[4,n.send(r)];case 1:return[2,i.sent().as(Et).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 $(he(pe,e)).throw(j.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Dt({userId:n.userId,templateName:e}),[4,r.send(i)];case 1:return[2,s.sent().as(Ut).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 $(e instanceof m||t("string",e)).throw(j.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new wt({userId:r.userId,blockedUserId:e instanceof m?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.blockUserWithUserId=function(e){return 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 $(e instanceof m||t("string",e)).throw(j.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new kt({userId:r.userId,unblockedUserId:e instanceof m?e.userId:e}),[4,i.send(s)];case 1:return o.sent(),[2]}}))}))},n.prototype.unblockUserWithUserId=function(e){return 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 $(t("string",e)).throw(j.invalidParameters),n=q.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Ot({userId:r.userId,token:e}),[4,i.send(s)];case 1:return o=a.sent(),[2,o.as(Lt).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=q.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new qt({userId:t.userId}),[4,n.send(r)];case 1:return i=s.sent(),[2,i.as(zt).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 $(t("boolean",e)).throw(j.invalidParameters),n=q.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=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Nt({userId:n.userId,discoveries:e}),[4,r.send(i)];case 1:return s=o.sent(),[2,s.as(At).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 $(A("string",e)).throw(j.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Mt({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 $(A("string",e)).throw(j.invalidParameters),t=q.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=o.sent(),[2,s.as(Ft).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 $(A("string",e)).throw(j.invalidParameters),t=q.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new jt({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=q.of(this._iid).requestQueue,t=new Kt,[4,e.send(t)];case 1:return n=r.sent(),[2,n.as(Vt).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=q.of(this._iid).requestQueue,n=new Bt({categoryId:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Jt).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=q.of(this._iid).requestQueue,n=new Xt({key:e}),[4,t.send(n)];case 1:return r=i.sent(),[2,r.as(Yt).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=q.of(this._iid),$(e.hasExtension("sb_uikit")).throw(j.notSupportedError),t=e.requestQueue,n=new Zt,[4,t.send(n)];case 1:return r=i.sent(),[2,r.as($t).uikitConfiguration]}}))}))},n}();export{nn as ApplicationUserListQuery,on as BlockedUserListQuery,Ve as ConnectionHandler,Ht as Emoji,Gt as EmojiCategory,Wt as EmojiContainer,cn as FriendListQuery,Ke as SessionHandler,Be as UserEventHandler,dn as default}; diff --git a/lib/__bundle-087816c3.js b/lib/__bundle-087816c3.js new file mode 100644 index 0000000..b0ece51 --- /dev/null +++ b/lib/__bundle-087816c3.js @@ -0,0 +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="object"==typeof e&&null!==e&&e.hasOwnProperty("name")&&"string"==typeof e.name&&e.hasOwnProperty("uri")&&"string"==typeof e.uri&&e.hasOwnProperty("type")&&"string"==typeof e.type;if(!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}(),I={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),s?(this._clearOrder=o,this._customClearOrderComparator=s):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}(),V=function(){function e(){}return Object.defineProperty(e.prototype,"hasSession",{get:function(){return!!this.sessionKey},enumerable:!1,configurable:!0}),e.prototype.clear=function(){this.authToken=void 0,this.sessionKey=void 0},e}(),Z=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)}))},W=function(){function e(e){var t=e.container;this._container={},this._container=t,this.key=Z()}return e.prototype._register=function(e,t,n){var r;return e in this._container||(this._container[e]=new Map),null===(r=this._container[e])||void 0===r||r.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(){var e;for(var t in this._container)null===(e=this._container[t])||void 0===e||e.delete(this.key)},e}(),H=function(){function e(){this._container={}}return e.prototype.on=function(e,t){return new W({container:this._container}).on(e,t)},e.prototype.once=function(e,t){return new W({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 H}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},J=function(e){if(null!=e){if("object"==typeof e){if(Array.isArray(e)){var t=c([],a(e),!1);for(var n in t)t[n]=J(t[n]);return t}for(var r in e)null===e[r]&&delete e[r];return e}return e}};!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 $,ee="v3",te="/".concat(ee,"/users"),ne="/".concat(ee,"/storage/file"),re="/".concat(ee,"/group_channels"),ie="/".concat(ee,"/sdk/group_channels"),oe="/".concat(ee,"/open_channels"),se="/".concat(ee,"/sdk/open_channels"),ae="/".concat(ee,"/search"),ce="/".concat(ee,"/report"),ue="/".concat(ee,"/emojis"),le="/".concat(ee,"/emoji_categories"),he="/".concat(ee,"/polls"),de="/".concat(ee,"/scheduled_messages"),_e="/".concat(ee,"/sdk/ui_kit/configuration"),fe="/".concat(ee,"/sdk/statistics"),pe=function(e){switch(e){case x.GROUP:return re;case x.OPEN:return oe;default:return null}},ge=function(e){switch(e){case x.GROUP:return"".concat(ce,"/group_channels");case x.OPEN:return"".concat(ce,"/open_channels");default:return null}},ve=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},Ee=function(e,t,n){var r,i,o,s,a=ve(null!==(r=e.mentionType)&&void 0!==r?r:null,null!==(i=e.mentionedUserIds)&&void 0!==i?i:[],n),c=ve(null!==(o=t.mentionType)&&void 0!==o?o:null,null!==(s=t.mentionedUserIds)&&void 0!==s?s:[],n);return!a&&c?1:a&&!c?-1:0},be=function(e,t,n){var r,i=t||new FormData;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){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=be(s,i,a)}return i};!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}($||($={}));var me,ye=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.params={},t.requireAuth=!0,t.headers={},t.requestId=Z(),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])}))?be(e):JSON.stringify(e)},enumerable:!1,configurable:!0}),n}(Y),we=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),Se=function(e){function n(t){var n=e.call(this)||this;return n.requestId=t,n}return t(n,e),n}(Y),ke=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),Te=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"}(me||(me={}));var Ce=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}(),Oe=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},Ae=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 Se&&c.cancel(e.requestId)})),this._logger=o,this._shouldImportFetchCompat=a}return Object.defineProperty(e.prototype,"_userAgentWithExtension",{get:function(){var e=this._sdkState.extensions,t=Oe()?"reactnative":"JS",n="//";if(e){var r=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",i=e.sb_uikit?"u".concat(e.sb_uikit):"",o=e["device-os-platform"]?"o".concat(e["device-os-platform"]):"";n="".concat(r,"/").concat(i,"/").concat(o)}return"".concat(t,"/c").concat(h.SDK_VERSION,"/").concat(n)},enumerable:!1,configurable:!0}),e.prototype._createHeader=function(e,t){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 Te(new Ce({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}})))},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=![$.GET,$.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:void 0),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=null),"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-b8f76515.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),[2,new we(this._iid,_)];throw _?(((f=new E(_)).isSessionKeyExpiredError||f.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new ke({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}(),Ne=function(e){function n(t,n,r,i){void 0===i&&(i="");var o,s=this;return(s=e.call(this)||this)._iid=t,s.code=n,s.payload=r,s.requestId=null!==(o=r.req_id)&&void 0!==o?o:i,s}return t(n,e),n.createFromRawMessage=function(e,t){var r=t.substring(0,4),i={};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),Re=function(){};function Ie(e){let t=e.length;for(;--t>=0;)e[t]=0}const De=256,Le=286,xe=30,Me=15,Pe=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]),Ue=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]),ze=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Fe=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),qe=new Array(576);Ie(qe);const Ge=new Array(60);Ie(Ge);const je=new Array(512);Ie(je);const Ke=new Array(256);Ie(Ke);const Be=new Array(29);Ie(Be);const Ve=new Array(xe);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 We,He,Qe;function Ye(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}Ie(Ve);const Xe=e=>e<256?je[e]:je[256+(e>>>7)],Je=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},$e=(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<{$e(e,n[2*t],n[2*t+1])},tt=(e,t)=>{let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1},nt=(e,t,n)=>{const r=new Array(16);let i,o,s=0;for(i=1;i<=Me;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]=tt(r[t]++,t))}},rt=e=>{let t;for(t=0;t{e.bi_valid>8?Je(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},ot=(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?et(e,i,t):(o=Ke[i],et(e,o+De+1,t),s=Pe[o],0!==s&&(i-=Be[o],$e(e,i,s)),r--,o=Xe(r),et(e,o,n),s=Ue[o],0!==s&&(r-=Ve[o],$e(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--)st(e,n,s);c=o;do{s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],st(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++,st(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<=Me;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),nt(n,u,e.bl_count)},ut=(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{$e(e,0+(r?1:0),3),it(e),Je(e,n),Je(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var _t=(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(ut(e,e.dyn_ltree,e.l_desc.max_code),ut(e,e.dyn_dtree,e.d_desc.max_code),ct(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*Fe[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?dt(e,t,n,r):4===e.strategy||o===i?($e(e,2+(r?1:0),3),at(e,qe,Ge)):($e(e,4+(r?1:0),3),((e,t,n,r)=>{let i;for($e(e,t-257,5),$e(e,n-1,5),$e(e,r-4,4),i=0;i{ht||((()=>{let e,t,n,r,i;const o=new Array(16);for(n=0,r=0;r<28;r++)for(Be[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*(Ke[n]+De+1)]++,e.dyn_dtree[2*Xe(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{$e(e,2,3),et(e,256,qe),(e=>{16===e.bi_valid?(Je(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 pt=(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 gt=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 vt=(e,t,n,r)=>{const i=gt,o=r+n;e^=-1;for(let n=r;n>>8^i[255&(e^t[n])];return-1^e},Et={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"},bt={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:yt,_tr_flush_block:wt,_tr_tally:St,_tr_align:kt}=ft,{Z_NO_FLUSH:Tt,Z_PARTIAL_FLUSH:Ct,Z_FULL_FLUSH:Ot,Z_FINISH:At,Z_BLOCK:Nt,Z_OK:Rt,Z_STREAM_END:It,Z_STREAM_ERROR:Dt,Z_DATA_ERROR:Lt,Z_BUF_ERROR:xt,Z_DEFAULT_COMPRESSION:Mt,Z_FILTERED:Pt,Z_HUFFMAN_ONLY:Ut,Z_RLE:zt,Z_FIXED:Ft,Z_DEFAULT_STRATEGY:qt,Z_UNKNOWN:Gt,Z_DEFLATED:jt}=bt,Kt=258,Bt=262,Vt=42,Zt=113,Wt=666,Ht=(e,t)=>(e.msg=Et[t],t),Qt=e=>2*e-(e>4?9:0),Yt=e=>{let t=e.length;for(;--t>=0;)e[t]=0},Xt=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 Jt=(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))},en=(e,t)=>{wt(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,$t(e.strm)},tn=(e,t)=>{e.pending_buf[e.pending++]=t},nn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},rn=(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=pt(e.adler,t,i,n):2===e.state.wrap&&(e.adler=vt(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)},on=(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-Bt?e.strstart-(e.w_size-Bt):0,u=e.window,l=e.w_mask,h=e.prev,d=e.strstart+Kt;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},sn=e=>{const t=e.w_size;let n,r,i;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Bt)&&(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),Xt(e),r+=t),0===e.strm.avail_in)break;if(n=rn(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=Jt(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=Jt(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,$t(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&&(rn(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&&(rn(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===At)&&t!==Tt&&0===e.strm.avail_in&&r<=i)&&(n=r>i?i:r,s=t===At&&0===e.strm.avail_in&&n===r?1:0,yt(e,e.block_start,n,s),e.block_start+=n,$t(e.strm)),s?3:1)},cn=(e,t)=>{let n,r;for(;;){if(e.lookahead=3&&(e.ins_h=Jt(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-Bt&&(e.match_length=on(e,n)),e.match_length>=3)if(r=St(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=Jt(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=Jt(e,e.ins_h,e.window[e.strstart+1]);else r=St(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(en(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===At?(en(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(en(e,!1),0===e.strm.avail_out)?1:2},un=(e,t)=>{let n,r,i;for(;;){if(e.lookahead=3&&(e.ins_h=Jt(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=St(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=Jt(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&&(en(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=St(e,0,e.window[e.strstart-1]),r&&en(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=St(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===At?(en(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(en(e,!1),0===e.strm.avail_out)?1:2};function ln(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 hn=[new ln(0,0,0,0,an),new ln(4,4,8,4,cn),new ln(4,5,16,8,cn),new ln(4,6,32,32,cn),new ln(4,4,16,16,un),new ln(8,16,32,32,un),new ln(8,16,128,128,un),new ln(8,32,128,256,un),new ln(32,128,258,1024,un),new ln(32,258,258,4096,un)];function dn(){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=jt,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),Yt(this.dyn_ltree),Yt(this.dyn_dtree),Yt(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),Yt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Yt(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 _n=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==Vt&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==Zt&&t.status!==Wt?1:0},fn=e=>{if(_n(e))return Ht(e,Dt);e.total_in=e.total_out=0,e.data_type=Gt;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?Vt:Zt,e.adler=2===t.wrap?0:1,t.last_flush=-2,mt(t),Rt},pn=e=>{const t=fn(e);var n;return t===Rt&&((n=e.state).window_size=2*n.w_size,Yt(n.head),n.max_lazy_match=hn[n.level].max_lazy,n.good_match=hn[n.level].good_length,n.nice_match=hn[n.level].nice_length,n.max_chain_length=hn[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},gn=(e,t,n,r,i,o)=>{if(!e)return Dt;let s=1;if(t===Mt&&(t=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),i<1||i>9||n!==jt||r<8||r>15||t<0||t>9||o<0||o>Ft||8===r&&1!==s)return Ht(e,Dt);8===r&&(r=9);const a=new dn;return e.state=a,a.strm=e,a.status=Vt,a.wrap=s,a.gzhead=null,a.w_bits=r,a.w_size=1<gn(e,t,jt,15,8,qt),deflateInit2:gn,deflateReset:pn,deflateResetKeep:fn,deflateSetHeader:(e,t)=>_n(e)||2!==e.state.wrap?Dt:(e.state.gzhead=t,Rt),deflate:(e,t)=>{if(_n(e)||t>Nt||t<0)return e?Ht(e,Dt):Dt;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===Wt&&t!==At)return Ht(e,0===e.avail_out?xt:Dt);const r=n.last_flush;if(n.last_flush=t,0!==n.pending){if($t(e),0===e.avail_out)return n.last_flush=-1,Rt}else if(0===e.avail_in&&Qt(t)<=Qt(r)&&t!==At)return Ht(e,xt);if(n.status===Wt&&0!==e.avail_in)return Ht(e,xt);if(n.status===Vt&&0===n.wrap&&(n.status=Zt),n.status===Vt){let t=jt+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=Ut||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,nn(n,t),0!==n.strstart&&(nn(n,e.adler>>>16),nn(n,65535&e.adler)),e.adler=1,n.status=Zt,$t(e),0!==n.pending)return n.last_flush=-1,Rt}if(57===n.status)if(e.adler=0,tn(n,31),tn(n,139),tn(n,8),n.gzhead)tn(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)),tn(n,255&n.gzhead.time),tn(n,n.gzhead.time>>8&255),tn(n,n.gzhead.time>>16&255),tn(n,n.gzhead.time>>24&255),tn(n,9===n.level?2:n.strategy>=Ut||n.level<2?4:0),tn(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(tn(n,255&n.gzhead.extra.length),tn(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=vt(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(tn(n,0),tn(n,0),tn(n,0),tn(n,0),tn(n,0),tn(n,9===n.level?2:n.strategy>=Ut||n.level<2?4:0),tn(n,3),n.status=Zt,$t(e),0!==n.pending)return n.last_flush=-1,Rt;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=vt(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=i,$t(e),0!==n.pending)return n.last_flush=-1,Rt;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=vt(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=vt(e.adler,n.pending_buf,n.pending-r,r)),$t(e),0!==n.pending)return n.last_flush=-1,Rt;r=0}t=n.gzindexr&&(e.adler=vt(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=vt(e.adler,n.pending_buf,n.pending-r,r)),$t(e),0!==n.pending)return n.last_flush=-1,Rt;r=0}t=n.gzindexr&&(e.adler=vt(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&&($t(e),0!==n.pending))return n.last_flush=-1,Rt;tn(n,255&e.adler),tn(n,e.adler>>8&255),e.adler=0}if(n.status=Zt,$t(e),0!==n.pending)return n.last_flush=-1,Rt}if(0!==e.avail_in||0!==n.lookahead||t!==Tt&&n.status!==Wt){let r=0===n.level?an(n,t):n.strategy===Ut?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(sn(e),0===e.lookahead)){if(t===Tt)return 1;break}if(e.match_length=0,n=St(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(en(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===At?(en(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(en(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===zt?((e,t)=>{let n,r,i,o;const s=e.window;for(;;){if(e.lookahead<=Kt){if(sn(e),e.lookahead<=Kt&&t===Tt)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+Kt;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=St(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=St(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(en(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===At?(en(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(en(e,!1),0===e.strm.avail_out)?1:2})(n,t):hn[n.level].func(n,t);if(3!==r&&4!==r||(n.status=Wt),1===r||3===r)return 0===e.avail_out&&(n.last_flush=-1),Rt;if(2===r&&(t===Ct?kt(n):t!==Nt&&(yt(n,0,0,!1),t===Ot&&(Yt(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),$t(e),0===e.avail_out))return n.last_flush=-1,Rt}return t!==At?Rt:n.wrap<=0?It:(2===n.wrap?(tn(n,255&e.adler),tn(n,e.adler>>8&255),tn(n,e.adler>>16&255),tn(n,e.adler>>24&255),tn(n,255&e.total_in),tn(n,e.total_in>>8&255),tn(n,e.total_in>>16&255),tn(n,e.total_in>>24&255)):(nn(n,e.adler>>>16),nn(n,65535&e.adler)),$t(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?Rt:It)},deflateEnd:e=>{if(_n(e))return Dt;const t=e.state.status;return e.state=null,t===Zt?Ht(e,Lt):Rt},deflateSetDictionary:(e,t)=>{let n=t.length;if(_n(e))return Dt;const r=e.state,i=r.wrap;if(2===i||1===i&&r.status!==Vt||r.lookahead)return Dt;if(1===i&&(e.adler=pt(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){0===i&&(Yt(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,sn(r);r.lookahead>=3;){let e=r.strstart,t=r.lookahead-2;do{r.ins_h=Jt(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,sn(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,Rt},deflateInfo:"pako deflate (from Nodeca project)"};const En=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var bn={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)En(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;yn[254]=yn[254]=1;var wn={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&&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+yn[e[n]]>t?n:t}};var Sn=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 kn=Object.prototype.toString,{Z_NO_FLUSH:Tn,Z_SYNC_FLUSH:Cn,Z_FULL_FLUSH:On,Z_FINISH:An,Z_OK:Nn,Z_STREAM_END:Rn,Z_DEFAULT_COMPRESSION:In,Z_DEFAULT_STRATEGY:Dn,Z_DEFLATED:Ln}=bt;function xn(e){this.options=bn.assign({level:In,method:Ln,chunkSize:16384,windowBits:15,memLevel:8,strategy:Dn},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 Sn,this.strm.avail_out=0;let n=vn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==Nn)throw new Error(Et[n]);if(t.header&&vn.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?wn.string2buf(t.dictionary):"[object ArrayBuffer]"===kn.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=vn.deflateSetDictionary(this.strm,e),n!==Nn)throw new Error(Et[n]);this._dict_set=!0}}function Mn(e,t){const n=new xn(t);if(n.push(e,!0),n.err)throw n.msg||Et[n.err];return n.result}xn.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?An:Tn,"string"==typeof e?n.input=wn.string2buf(e):"[object ArrayBuffer]"===kn.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===Cn||o===On)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(i=vn.deflate(n,o),i===Rn)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=vn.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Nn;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},xn.prototype.onData=function(e){this.chunks.push(e)},xn.prototype.onEnd=function(e){e===Nn&&(this.result=bn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Pn={Deflate:xn,deflate:Mn,deflateRaw:function(e,t){return(t=t||{}).raw=!0,Mn(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,Mn(e,t)},constants:bt};const Un=16209;var zn=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=Un;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=Un;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,R,I=null;for(p=0;p<=Fn;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=I[s[g]-f],R=T[s[g]-f]):(N=96,R=0),u=1<>y)+l]=A<<24|N<<16|R|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:Vn,Z_BLOCK:Zn,Z_TREES:Wn,Z_OK:Hn,Z_STREAM_END:Qn,Z_NEED_DICT:Yn,Z_STREAM_ERROR:Xn,Z_DATA_ERROR:Jn,Z_MEM_ERROR:$n,Z_BUF_ERROR:er,Z_DEFLATED:tr}=bt,nr=16180,rr=16190,ir=16191,or=16192,sr=16194,ar=16199,cr=16200,ur=16206,lr=16209,hr=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function dr(){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 _r=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},fr=e=>{if(_r(e))return Xn;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=nr,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},pr=e=>{if(_r(e))return Xn;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,fr(e)},gr=(e,t)=>{let n;if(_r(e))return Xn;const r=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Xn:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,pr(e))},vr=(e,t)=>{if(!e)return Xn;const n=new dr;e.state=n,n.strm=e,n.window=null,n.mode=nr;const r=gr(e,t);return r!==Hn&&(e.state=null),r};let Er,br,mr=!0;const yr=e=>{if(mr){Er=new Int32Array(512),br=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(Bn(1,e.lens,0,288,Er,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Bn(2,e.lens,0,32,br,0,e.work,{bits:5}),mr=!1}e.lencode=Er,e.lenbits=9,e.distcode=br,e.distbits=5},wr=(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.whavevr(e,15),inflateInit2:vr,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(_r(e)||!e.output||!e.input&&0!==e.avail_in)return Xn;n=e.state,n.mode===ir&&(n.mode=or),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 nr:if(0===n.wrap){n.mode=or;break}for(;l<16;){if(0===a)break e;a--,u+=r[o++]<>>8&255,n.check=vt(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=lr;break}if((15&u)!==tr){e.msg="unknown compression method",n.mode=lr;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=lr;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(T[0]=255&u,T[1]=u>>>8&255,n.check=vt(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=vt(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=vt(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=vt(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=vt(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=ir;break;case 16189:for(;l<32;){if(0===a)break e;a--,u+=r[o++]<>>=7&l,l-=7&l,n.mode=ur;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(yr(n),n.mode=ar,t===Wn){u>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=lr}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=lr;break}if(n.length=65535&u,u=0,l=0,n.mode=sr,t===Wn)break e;case sr: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=ir;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=lr;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=Bn(0,n.lens,0,19,n.lencode,0,n.work,C),n.lenbits=C.bits,S){e.msg="invalid code lengths set",n.mode=lr;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=lr;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=lr;break}for(;_--;)n.lens[n.have++]=w}}if(n.mode===lr)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=lr;break}if(n.lenbits=9,C={bits:n.lenbits},S=Bn(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=lr;break}if(n.distbits=6,n.distcode=n.distdyn,C={bits:n.distbits},S=Bn(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=lr;break}if(n.mode=ar,t===Wn)break e;case ar:n.mode=cr;case cr: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,zn(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===ir&&(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=ir;break}if(64&v){e.msg="invalid literal/length code",n.mode=lr;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=lr;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=lr;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=lr;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=cr);break;case 16205:if(0===c)break e;i[s++]=n.length,c--,n.mode=cr;break;case ur:if(n.wrap){for(;l<32;){if(0===a)break e;a--,u|=r[o++]<{if(_r(e))return Xn;let t=e.state;return t.window&&(t.window=null),e.state=null,Hn},inflateGetHeader:(e,t)=>{if(_r(e))return Xn;const n=e.state;return 0==(2&n.wrap)?Xn:(n.head=t,t.done=!1,Hn)},inflateSetDictionary:(e,t)=>{const n=t.length;let r,i,o;return _r(e)?Xn:(r=e.state,0!==r.wrap&&r.mode!==rr?Xn:r.mode===rr&&(i=1,i=pt(i,t,n,0),i!==r.check)?Jn:(o=wr(e,t,n,n),o?(r.mode=16210,$n):(r.havedict=1,Hn)))},inflateInfo:"pako inflate (from Nodeca project)"};var kr=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 Tr=Object.prototype.toString,{Z_NO_FLUSH:Cr,Z_FINISH:Or,Z_OK:Ar,Z_STREAM_END:Nr,Z_NEED_DICT:Rr,Z_STREAM_ERROR:Ir,Z_DATA_ERROR:Dr,Z_MEM_ERROR:Lr}=bt;function xr(e){this.options=bn.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 Sn,this.strm.avail_out=0;let n=Sr.inflateInit2(this.strm,t.windowBits);if(n!==Ar)throw new Error(Et[n]);if(this.header=new kr,Sr.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=wn.string2buf(t.dictionary):"[object ArrayBuffer]"===Tr.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=Sr.inflateSetDictionary(this.strm,t.dictionary),n!==Ar)))throw new Error(Et[n])}function Mr(e,t){const n=new xr(t);if(n.push(e),n.err)throw n.msg||Et[n.err];return n.result}xr.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?Or:Cr,"[object ArrayBuffer]"===Tr.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=Sr.inflate(n,s),o===Rr&&i&&(o=Sr.inflateSetDictionary(n,i),o===Ar?o=Sr.inflate(n,s):o===Dr&&(o=Rr));n.avail_in>0&&o===Nr&&n.state.wrap>0&&0!==e[n.next_in];)Sr.inflateReset(n),o=Sr.inflate(n,s);switch(o){case Ir:case Dr:case Rr:case Lr:return this.onEnd(o),this.ended=!0,!1}if(a=n.avail_out,n.next_out&&(0===n.avail_out||o===Nr))if("string"===this.options.to){let e=wn.utf8border(n.output,n.next_out),t=n.next_out-e,i=wn.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!==Ar||0!==a){if(o===Nr)return o=Sr.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},xr.prototype.onData=function(e){this.chunks.push(e)},xr.prototype.onEnd=function(e){e===Ar&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=bn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Pr={Inflate:xr,inflate:Mr,inflateRaw:function(e,t){return(t=t||{}).raw=!0,Mr(e,t)},ungzip:Mr,constants:bt};const{Deflate:Ur,deflate:zr,deflateRaw:Fr,gzip:qr}=Pn,{Inflate:Gr,inflate:jr,inflateRaw:Kr,ungzip:Br}=Pr;var Vr,Zr={Deflate:Ur,deflate:zr,deflateRaw:Fr,gzip:qr,Inflate:Gr,inflate:jr,inflateRaw:Kr,ungzip:Br,constants:bt};!function(e){e.CONNECTING="CONNECTING",e.OPEN="OPEN",e.CLOSED="CLOSED"}(Vr||(Vr={}));var Wr,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===Vr.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){if(this._ws)switch(this._ws.readyState){case 0:return Vr.CONNECTING;case 1:return Vr.OPEN}return Vr.CLOSED},enumerable:!1,configurable:!0}),n.prototype._handleMessage=function(e){var t=this;e.split("\n").forEach((function(e){if(e){var n=Ne.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 ke(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!==Vr.CLOSED?(e._ws.onopen=Re,e._ws.onmessage=Re,e._ws.onerror=Re,e._ws.onclose=function(){e.dispatch("close"),t()},e._ws.close(),e._ws=void 0):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}(H),Qr=function(e){function n(t){var n,r=t.code,i=t.ackRequired,o=t.payload,s=void 0===o?{}: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:Z(),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),Yr=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),Xr=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=n}))},Jr=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 Ae(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 Yr(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(!this._sdkState.websocket)throw E.connectionRequired;if(t=new Xr,e.ackRequired){r=function(r,o){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(void 0,e)},reject:function(e){return r(e)}}),this.websocketClient.send(e)}catch(e){r(e)}}else try{this.websocketClient.send(e),t.resolve()}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 ye?[4,this._sendApiRequest(e)]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return e instanceof Qr?[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"}(Wr||(Wr={}));var $r=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),ei=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=Wr.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new Jr(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 $r){var t=e.stateType;switch(l._currentConnectionStateType=t,t){case Wr.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 Wr.INITIALIZED:case Wr.INTERNAL_DISCONNECTED:case Wr.EXTERNAL_DISCONNECTED:case Wr.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===Wr.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLazyCallActivated",{get:function(){return this._currentConnectionStateType===Wr.CONNECTING||this._currentConnectionStateType===Wr.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 Qr?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 Xr,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:case 7:return[3,9];case 4:return e instanceof ye?this._auth.hasSession?(this._logger.debug("send api request",e),[4,this.commandRouter.send(e)]):[3,6]:[3,8];case 6:if(this.isLazyCallActivated)return this._logger.debug("wait api request",e),t=new Xr,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 8:throw E.invalidCommand;case 9: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}(),ti="sendbird@devicetokens",ni=function(){function e(e){var t=e.type,n=e.token;this.type=t,this.token=n}return e.payloadify=function(e){return X(J({type:e.type,token:e.token}))},e}(),ri=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(te,"/").concat(n,"/session_key"),s.method=$.POST,s.params={token:r,expiring_session:!!o},s.requireAuth=!1,s}return t(n,e),n}(ye),ii=function(e){function n(t){var n=t.authToken,r=t.expiringSession,i=void 0===r||r,o=t.requestId,s=void 0===o?"":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}(Qr),oi=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}(we),si=function(e){function n(t,n,r){var i,o=this;return(o=e.call(this,t,"LOGI",r)||this).error=null,o.newKey=null,o.newKey=null!==(i=r.new_key)&&void 0!==i?i:null,o.error=r.error?new E(r.error):null,o}return t(n,e),n}(Ne),ai=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(Y),ci=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)}))]}))}))},ui=function(){function e(){}return e.prototype.calcTimeout=function(){return 0},e}(),li=function(e,t,n){return void 0===n&&(n=new ui),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 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 new ii({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(si),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 ri({userId:this._sdkState.userId,authToken:e,expiringSession:!0}),[4,li((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(oi).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;return o(this,(function(o){switch(o.label){case 0:if(this._currentConnectionStateType!==Wr.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?[4,this._receiveNewAuthToken()]:[3,9];case 4:return(i=o.sent())?(this.auth.authToken=i,[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 r=o.sent(),this._isSessionRelatedError(r)?t?[4,this._receiveNewAuthToken()]:[3,18]:[3,20];case 13:return(i=o.sent())?(this.auth.authToken=i,[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 r;case 19:return[3,21];case 20:throw r;case 21:return[3,22];case 22:return[2]}}))}))},n.prototype._receiveNewAuthToken=function(){var e=this,t=new Xr;return hi((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,_i.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(ti)]:[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(ti,{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(),_i.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,[4,this.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))},n}(H),pi=function(){function e(){this.type=Wr.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}(),gi=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=Wr.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 wi,t)];case 2:return s.sent(),hi((function(){return i(r,void 0,void 0,(function(){return o(this,(function(t){return e.connectionHandlers.forEach((function(e){e.onDisconnected&&e.onDisconnected(n)})),[2]}))}))})),[2]}}))}))},n}(pi),vi=function(e){function n(){var t=e.call(this)||this;return t.type=Wr.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 yi({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 bi,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 gi,t)];case 1:return n.sent(),[2]}}))}))},n}(pi),Ei=function(e){function n(t){var n=t.autoReconnect,r=e.call(this)||this;return r.type=Wr.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 bi,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 yi({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 bi,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 vi,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 gi,t)];case 1:return n.sent(),[2]}}))}))},n}(pi),bi=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=Wr.RECONNECTING,t.name="reconnecting",t._callbacks=[],t}return t(n,e),n.prototype._halt=function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=void 0)},n.prototype._flushCallbacks=function(e){this._haltConnect=void 0,this._resetConnect=void 0,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 Xr,this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),hi((function(){return i(l,void 0,void 0,(function(){return o(this,(function(t){return e.connectionHandlers.forEach((function(e){e.onReconnectStarted&&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,li((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 mi,t)];case 3:return h.sent(),hi((function(){return i(l,void 0,void 0,(function(){return o(this,(function(t){return this._flushCallbacks(),e.connectionHandlers.forEach((function(e){e.onReconnectSucceeded&&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 Ei({autoReconnect:!1}),t)]:[3,6];case 5:h.sent(),h.label=6;case 6:return hi((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&&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 Xr,this._halt(E.connectionCanceled),e.cancelConnectForRetry(),this._callbacks.push((function(){var r=Date.now();e.changeState(new yi({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 Xr,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 Ei({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 vi,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 gi,t)];case 1:return n.sent(),[2]}}))}))},n}(pi),mi=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=Wr.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 bi,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 Ei({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 vi,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 gi,t)];case 1:return n.sent(),[2]}}))}))},n}(pi),yi=function(e){function n(t){var n=t.authToken,r=e.call(this)||this;return r.type=Wr.CONNECTING,r.name="connecting",r._authToken="",r._callbacks=[],r._authToken=n,r}return t(n,e),n.prototype._halt=function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=void 0)},n.prototype._flushCallbacks=function(e){this._haltConnect=void 0,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 Xr,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,li((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 mi,t)];case 3:return a.sent(),hi((function(){return i(s,void 0,void 0,(function(){return o(this,(function(t){return this._flushCallbacks(),e.connectionHandlers.forEach((function(t){t.onConnected&&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 wi,t)]:[3,7];case 6:a.sent(),a.label=7;case 7:return hi((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 Xr,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,a=void 0!==s&&s;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 Ei({autoReconnect:a}),t)]:[3,2];case 1:return n.sent(),[3,4];case 2:return[4,e.changeState(new gi,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 vi,t)]:[3,2];case 1:return n.sent(),[3,4];case 2:return[4,e.changeState(new gi,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 gi,t)];case 1:return n.sent(),[2]}}))}))},n}(pi),wi=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=Wr.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 yi({authToken:t}),n)];case 1:return r.sent(),[2]}}))}))},n}(pi),Si=function(e){function n(){return e.call(this,{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})||this}return t(n,e),n}(Qr),ki=function(){function e(e){var t=e.pingDelegate,n=e.sdkState,r=e.logger;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;if(!this.sdkState.websocket)throw E.connectionRequired;var n=new Si;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()}),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=void 0),this.pingDelegate.error()}return n},e.prototype.pong=function(){this._logger.debug("pinger.pong()"),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)},e.prototype.refreshTimer=function(){var e,t=this;if(!this.sdkState.websocket)throw E.connectionRequired;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=void 0),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)},e}(),Ti=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(J({last_updated_at:e.lastUpdatedAt}))},e}(),Ci=1048576,Oi=5,Ai=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*Ci: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 Ti(null!==(o=e.uikit_config)&&void 0!==o?o:{})}return e.payloadify=function(e){return X(J({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/Ci,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,uikit_config:e.uikitConfigInfo?Ti.payloadify(e.uikitConfigInfo):null}))},e}(),Ni=function(){function e(e){this._iid="",this._iid=e}return e.payloadify=function(e){return{}},e}(),Ri=function(e){function n(t){var n=t.userId,r=t.metadata,i=e.call(this)||this;return i.method=$.POST,i.path="".concat(te,"/").concat(n,"/metadata"),i.params={metadata:r},i}return t(n,e),n}(ye),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}(we),Di=function(e){function n(t){var n=t.userId,r=t.metadata,i=t.upsert,o=e.call(this)||this;return o.method=$.PUT,o.path="".concat(te,"/").concat(n,"/metadata"),o.params={metadata:r,upsert:i},o}return t(n,e),n}(ye),Li=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.metadata=n,r}return t(n,e),n}(we),xi=function(e){function n(t){var n=t.userId,r=t.metadataKey,i=e.call(this)||this;return i.method=$.DELETE,i.path="".concat(te,"/").concat(n,"/metadata/").concat(r),i}return t(n,e),n}(ye);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(we);var Mi=function(e){function n(t){var n=t.userId,r=e.call(this)||this;return r.method=$.DELETE,r.path="".concat(te,"/").concat(n,"/metadata"),r}return t(n,e),n}(ye);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(we);var Pi,Ui=function(e,t){var n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},zi=function(e,t){var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},Fi=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"}(Pi||(Pi={}));var qi,Gi=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=Pi.NON_AVAILABLE,S(Pi,n.is_online)?v.connectionStatus=n.is_online:w("boolean",n.is_online)&&(v.connectionStatus=n.is_online?Pi.ONLINE:Pi.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 X(J(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})))},Object.defineProperty(r.prototype,"profileUrl",{get:function(){var e=no.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 Ui(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 Fi(this._isValidMetaData(e)).throw(E.invalidParameters),t=no.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Ri({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 Fi(this._isValidMetaData(e)).throw(E.invalidParameters),n=no.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Di({userId:r.userId,metadata:e,upsert:t}),[4,i.send(s)];case 1:return a=o.sent(),c=a.as(Li).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 Fi(w("string",e)).throw(E.invalidParameters),t=no.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new xi({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=no.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Mi({userId:t.userId}),[4,n.send(r)];case 1:return i.sent(),this.metaData={},[2]}}))}))},r}(Ni),ji=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),Ki=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 Ai(t),this.user=new Gi(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 X(J(n(n(n({},Gi.payloadify(e.user)),Ai.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=no.of(this._iid);r.sdkState.websocket&&(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 ji({userProfile:this}))},e}(),Bi=function(e){function r(t,n,r){var i,o,s,a=this;return(a=e.call(this,t,n,r)||this).error=null,a.userProfile=new Ki(t,r),a.deviceTokenLastDeletedAt=null!==(i=r.device_token_last_deleted_at)&&void 0!==i?i:0,a.key=null!==(o=r.key)&&void 0!==o?o:"",a.ekey=null!==(s=r.ekey)&&void 0!==s?s:"",a.error=r.error?new E(r):null,a}return t(r,e),r.asError=function(e){return new r("","LOGI",n({user_id:"",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=no.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}(Ne),Vi=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,i=n.sdkState,o=n.cacheContext,s=n.connectionHandlers,a=n.sessionManager,c=n.websocketClient,u=n.dispatcher,l=n.logger,h=n.entryState,d=void 0===h?new wi:h,_=this;return(_=e.call(this)||this)._stateUpdatedAt=0,_._connectingAt=0,_._connectionRequestQueue=[],_._iid=t,_.sdkState=i,_.cacheContext=o,_.connectionHandlers=s,_._sessionManager=a,_._websocketClient=c,_._dispatcher=u,_._logger=l,_._currentState=d,(null===(r=_.sdkState.websocket)||void 0===r?void 0:r.pingerDisabled)||(_._pinger=new ki({pingDelegate:{send:function(e){return _._websocketClient.send(e)},error:function(e){return _._websocketClient.error(e)}},sdkState:_.sdkState,logger:l})),_._websocketClient.on("open",(function(){_._tryResolveConnectionRequest()})).on("message",(function(e){if("LOGI"===e.code)_.clearLoginTimer(),_._dispatcher.dispatch(e.as(Bi))})).on("ping-refresh",(function(){var e;return null===(e=_._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(function(){var e;return null===(e=_._pinger)||void 0===e?void 0:e.pong()})).on("error",(function(){var e;return null===(e=_._pinger)||void 0===e?void 0:e.stop()})).on("close",(function(){_._logiProcessingTimer=setTimeout((function(){_._logiProcessingTimer=void 0,_._unresolvedLogi||_._rejectConnectionRequest(E.networkError)}),500)})),_._dispatcher.on((function(e){e instanceof Bi&&(_._unresolvedLogi=e,_._tryResolveConnectionRequest())})),_}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 $r({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=void 0,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===(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=void 0,(t.error.isSessionKeyExpiredError||t.error.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new ke({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,n,r;void 0===e&&(e="");var i=this.sdkState,o=i.appId,s=i.appVersion,a=i.userId;i.extensions;var c=this.cacheContext.localCacheEnabled,u=this._sessionManager.auth,l=null===(t=this.sdkState.websocket)||void 0===t?void 0:t.compression,d=null!==(n=this.sdkState.extensions)&&void 0!==n?n:{},_=!!d.sb_uikit,f=d.sb_syncmanager?"s".concat(d.sb_syncmanager):"",p=d.sb_uikit?"u".concat(d.sb_uikit):"",g="JS/c".concat(h.SDK_VERSION,"/").concat(f,"/").concat(p);return"".concat(null===(r=this.sdkState.websocket)||void 0===r?void 0:r.host,"/?p=JS&pv=").concat(encodeURIComponent(h.OS_VERSION),"&sv=").concat(encodeURIComponent(h.SDK_VERSION),"&ai=").concat(o).concat(s?"&av=".concat(s):"").concat(u.hasSession?"&key=".concat(encodeURIComponent(u.sessionKey)):"&user_id=".concat(encodeURIComponent(a),"&access_token=").concat(encodeURIComponent(e)),"&pmce=").concat(l?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(g,"&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(c?1:0,"&include_poll_details=1").concat(_?"&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 Vi({request:t,features:n,options:i}))},n.prototype._statLogConnection=function(e){var t;this._dispatcher.dispatch(new Te(new Ce({type:me.WEBSOCKET_CONNECT,data:{host_url:null===(t=this.sdkState.websocket)||void 0===t?void 0:t.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){var t;return void 0===e&&(e=""),i(this,void 0,void 0,(function(){var n,r,i=this;return o(this,(function(o){return this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=void 0,this._rejectConnectionRequest(E.connectionCanceled)),n=this._url(e),r=new Xr,this._connectionRequestQueue.push(r),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){i._loginTimer=void 0,i._rejectConnectionRequest(E.loginTimeout)}),null===(t=this.sdkState.websocket)||void 0===t?void 0:t.responseTimeout),e&&(this._sessionManager.auth.authToken=e),this._websocketClient.connect(n)),[2,r.promise]}))}))},n.prototype.cancelConnectForRetry=function(){this._dispatcher.dispatch(Bi.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=void 0,this._unresolvedLogi=void 0,[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=void 0)},n}(H),Wi=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._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=void 0),this._websocketEventDispatcherContext&&(this._websocketEventDispatcherContext.close(),this._websocketEventDispatcherContext=void 0)},Object.defineProperty(e.prototype,"isConnected",{get:function(){return this._context.currentState.type===Wr.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isConnecting",{get:function(){var e=this._context.currentState;return e.type===Wr.CONNECTING||e.type===Wr.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 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}(Ce),Qi=function(e){function n(t){var n=t.deviceId,r=t.statLogs,i=e.call(this)||this;return i.method=$.POST,i.path="".concat(fe),i.params={device_id:n,log_entries:r.map((function(e){return Ce.payloadify(e)}))},i}return t(n,e),n}(ye),Yi=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[_]=Yi(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"}(qi||(qi={}));var Xi,Ji=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=qi.PENDING,h.isFlushing=!1,h.generation=1,h.lastFlushedAt=0,h._collectRequestStat=!0,h._collectFeatureLocalCacheStat=!0,h.deviceId=Z(),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===qi.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===me.API_RESULT||e.type===me.WEBSOCKET_CONNECT}))),!1)),this._collectFeatureLocalCacheStat&&e.push.apply(e,c([],a(this.queue.filter((function(e){return e.type===me.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!==qi.ENABLED?[3,2]:[4,this.cacheContext.preference.set(this.key,{deviceId:this.deviceId,statLogs:this.queue.map((function(e){return Ce.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 Qi({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=qi.DISABLED,[3,8];case 7:i.code===u.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=qi.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 Ce({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,ci(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 Te){var t=e.statLog;r.put(t)}else if(e instanceof Vi){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?qi.ENABLED:qi.COLLECT_ONLY:r.enabledState=qi.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===qi.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=Yi(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=void 0)},n}(H);!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"}(Xi||(Xi={}));var $i,eo=function(){function e(){this.level=Xi.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 X(J(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 uo.payloadify(e)})),created_by:t.createdBy,allow_user_suggestion:t.allowUserSuggestion,allow_multiple_votes:t.allowMultipleVotes,voted_option_ids:t.votedPollOptionIds})))},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),"number"==typeof r.voter_count&&(this.voterCount=r.voter_count),!0},r.prototype.serialize=function(){return Ui(this)},r}(Ni);!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"}(io||(io={}));var ho=function(e){return e.startsWith("EVENT_")||e.startsWith("LOCAL_MESSAGE_")||e===io.SYNC_MESSAGE_FILL||e===io.SYNC_MESSAGE_CHANGELOGS||e===io.SYNC_POLL_CHANGELOGS},_o=function(e){function n(t){var n=t.messages,r=t.source,i=t.isWebSocketEventComing,o=void 0!==i&&i,s=e.call(this)||this;return s.messages=n,s.source=r,s.isWebSocketEventComing=o,s}return t(n,e),n}(Y),fo=function(e){function n(t){var n=t.messageIds,r=t.source,i=t.isWebSocketEventComing,o=void 0!==i&&i,s=e.call(this)||this;return s.messageIds=n,s.source=r,s.isWebSocketEventComing=o,s}return t(n,e),n}(Y),po=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),go=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),vo=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),Eo=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),bo=function(){function e(e,t){var n;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}(),mo=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}(bo);export{ne as $,$ as A,bo as B,Vr as C,Yr as D,H as E,ji as F,Ki as G,ke as H,d as I,di as J,s as K,B as L,S as M,_ as N,p as O,f as P,x as Q,K as R,E as S,Xi as T,Gi as U,no as V,Ne as W,M as X,Ti as Y,Pi as Z,t as _,w as a,Ni as a0,y as a1,P as a2,Ui as a3,F as a4,j as a5,C as a6,U as a7,lo as a8,G as a9,ce as aA,Ee as aB,z as aC,v as aD,Eo as aE,N as aF,vo as aG,po as aH,ie as aI,de as aJ,oo as aK,ho as aL,Hi as aM,me as aN,li as aO,so as aP,se as aQ,oe as aR,Qr as aa,pe as ab,ve as ac,u as ad,ci as ae,Xr as af,q as ag,re as ah,io as ai,_o as aj,fo as ak,ae as al,mo as am,ro as an,uo as ao,$i as ap,Y as aq,O as ar,I as as,r as at,he as au,co as av,ao as aw,go as ax,Oi as ay,ge as az,i as b,o as c,te as d,X as e,ye as f,n as g,we as h,A as i,le as j,ue as k,_e as l,T as m,Re as n,R as o,Z as p,Oe as q,c as r,a as s,Fi as t,J as u,l as v,zi as w,$r as x,Wr as y,hi as z}; diff --git a/lib/__bundle-1ef675e5.js b/lib/__bundle-1ef675e5.js new file mode 100644 index 0000000..c45ef91 --- /dev/null +++ b/lib/__bundle-1ef675e5.js @@ -0,0 +1 @@ +import{a7 as e,a2 as t,ag as n,b as r,K as i,c as s,g as a,a as o,i as c,_ as u,S as l,a0 as h,t as d,aq as f,a5 as _,ar as v,x as p,y as m,ad as y,aj as E,ai as b,U as g,W as N,r as I,s as w,as as A,at as T}from"./__bundle-087816c3.js";import{U as O,s as C,v as S,j as L,k,l as R,m as x,n as D,F as P,o as M,b as B,D as H}from"./__bundle-50274a15.js";import{S as U,U as V,F as K,b as q,c as F}from"./__bundle-80fd264e.js";var j,G,z;!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"}(j||(j={})),function(e){e.CHRONOLOGICAL="chronological",e.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",e.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical"}(G||(G={})),function(e){e.CREATED_AT="created_at",e.SCHEDULED_AT="scheduled_at"}(z||(z={}));var W,Y=function(e){switch(e){case j.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case j.CHRONOLOGICAL:return["-createdAt","syncIndex"];case j.CHANNEL_NAME_ALPHABETICAL:return["name"];default:return["-lastMessageUpdatedAt","-createdAt","syncIndex"]}},Q=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 U))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 U&&r.parentMessageId>0&&!r.replyToChannel)return!1}return!0},r}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(W||(W={}));var J,Z,X=function(e){switch(e){case W.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case W.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},$=function(){return"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product},ee=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"}(J||(J={})),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"}(Z||(Z={}));var te,ne={},re=function(){function e(e,t){void 0===t&&(t={});var n=this;return this._state=J.PROCESSING,this._queue=[],this._activationQueue=[],ne[e]&&!t.forceCreate||(this.nodeId=ee(),this.key=e,$()&&(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 Z.NEWNODE:n._sendSync();break;case Z.CLAIM_HOST:n._sendSync(),n._hostId=a;break;case Z.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:Z.REQUEST_LOCK,ts:e.ts})};try{for(var v=i(f),p=v.next();!p.done;p=v.next()){_(p.value)}}catch(e){t={error:e}}finally{try{p&&!p.done&&(r=v.return)&&r.call(v)}finally{if(t)throw t.error}}n._currentItem=n._queue.find((function(e){return e.requestId===d})),n._completeSync()}break;case Z.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 Z.REQUEST_LOCK:n._requestLock(s);break;case Z.ACQUIRE_LOCK:var m=n._queue.find((function(e){return e.requestId===o}));n._acquire(m);break;case Z.RELEASE_LOCK:n._release(o)}})),window.addEventListener("beforeunload",(function(){n._send(Z.REMOVENODE)}))),ne[e]=this),ne[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==J.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:ee(),key:this.key,op:e,data:t.data,ts:Date.now()};return $()&&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(Z.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(Z.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(Z.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=J.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])},e.prototype.registerNode=function(){this._send(Z.NEWNODE),this._waitSync()},e.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(Z.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(Z.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}(),ie=a(a({},O),{scheduledAt:void 0}),se=function(e){return S(e)&&o("number",e.scheduledAt,!0)},ae=a(a({},L),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),oe=function(e){return R(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})))},ce="UnsentMessage",ue="reqId",le={},he=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,le[t]=s,s._mutex=new re("unsendmessagecache.lock"),s}return u(t,e),t.of=function(e){return le[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb,t=null==e?void 0:e.collection(ce);if(!t)throw l.databaseError;return t},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=C(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,a(a({},C(t)),{scheduledAt:t.scheduledAt})))):e instanceof K?(e.messageParams&&(n.messageParams=k(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return a(a({},k(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))):e instanceof q&&e.messageParams&&(n.messageParams=x(e.messageParams)),n},t.prototype._deserialize=function(e){return e=a(a({},e),{messageId:parseInt(e.messageId)}),F.of(this._iid).buildMessageFromSerializedData(e)},t.prototype._deserializeWithMessageCreateParams=function(e){var t,n,i;return r(this,void 0,void 0,(function(){var a,o,c,u,l,h,d=this;return s(this,(function(f){switch(f.label){case 0:return a=F.of(this._iid),o=this._deserialize(e),e.messageParams?o instanceof V?(u=e.messageParams,o.messageParams=a.buildUserMessageCreateParamsFromSerializedData(u,o),[3,6]):[3,1]:[3,6];case 1:return o instanceof K?(u=e.messageParams).fileKey&&"string"==typeof u.fileKey&&D(null!==(t=u.fileType)&&void 0!==t?t:"")?(c=u,[4,this.collection.getBlob(u.fileKey)]):[3,3]:[3,4];case 2:c.file=null!==(n=f.sent())&&void 0!==n?n:void 0,f.label=3;case 3:return o.messageParams=a.buildFileMessageCreateParamsFromSerializedData(u,o),[3,6];case 4:return o instanceof q&&((u=e.messageParams)&&u.fileInfoList)?(o.messageParams=a.buildMultipleFilesMessageCreateParamsFromSerializedData(u,o),[4,Promise.all(o.messageParams.fileInfoList.map((function(e){return r(d,void 0,void 0,(function(){var t,n,r,i,a;return s(this,(function(s){switch(s.label){case 0:return"string"==typeof(null===(n=e._uploadedMetaData)||void 0===n?void 0:n.fileKey)&&D(null!==(i=null===(r=e._uploadedMetaData)||void 0===r?void 0:r.fileType)&&void 0!==i?i:"")?(t=e,[4,this.collection.getBlob(e._uploadedMetaData.fileKey)]):[3,2];case 1:t.file=null!==(a=s.sent())&&void 0!==a?a:void 0,s.label=2;case 2:return[2]}}))}))})))]):[3,6];case 5:f.sent(),f.label=6;case 6:return o.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams?o instanceof V?(l=e.scheduledInfo.scheduledMessageParams,o.scheduledInfo.scheduledMessageParams=a.buildScheduledUserMessageCreateParamsFromSerializedData(l,o),[3,10]):[3,7]:[3,10];case 7:return o instanceof K?(l=e.scheduledInfo.scheduledMessageParams).fileKey&&"string"==typeof l.fileKey&&"string"==typeof l.fileType&&D(l.fileType)?(h=l,[4,this.collection.getBlob(l.fileKey)]):[3,9]:[3,10];case 8:h.file=null!==(i=f.sent())&&void 0!==i?i:void 0,f.label=9;case 9:o.scheduledInfo.scheduledMessageParams=a.buildScheduledFileMessageCreateParamsFromSerializedData(l,o),f.label=10;case 10:return[2,o]}}))}))},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,void 0]}}))}))},t.prototype.fetch=function(e){var t=e.channelUrl,n=e.filter,i=void 0===n?new Q:n,a=e.order,o=void 0===a?W.CHANNEL_LATEST:a,c=e.sendingStatus,u=e.backward,l=void 0!==u&&u,h=e.parentMessageId;return r(this,void 0,void 0,(function(){var e,n,a,u,d=this;return s(this,(function(f){switch(f.label){case 0:return this.localCacheEnabled?(e=X(o),n={"/where":function(e){return!!(o!==W.NEWEST_CHILD_MESSAGE||h&&0!==e.parentMessageId&&e.parentMessageId===h)&&i.match(d._deserialize(e))}},t&&(n.channelUrl=t),c&&(n.sendingStatus=c),a={where:n,index:e,backward:l},[4,this.collection.query(a)]):[3,3];case 1:return[4,f.sent().fetch({})];case 2:return u=f.sent(),[2,Promise.all(u.map((function(e){return r(d,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 Q),r(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,this.fetch({filter:t,order:W.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 q?[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;return s(this,(function(n){switch(n.label){case 0:return t=[],e.threadInfo&&e.threadInfo.replyCount>0?[4,this.getAllChildMessages(e)]:[3,2];case 1:t=n.sent(),n.label=2;case 2:return t.length>0?(t.forEach((function(t){return t.applyParentMessage(e)})),[4,this.upsert(t)]):[3,4];case 3:n.sent(),n.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&&M(i.file)?[4,this.collection.saveBlob(i.file,e.reqId)]:[3,2]:[3,5];case 1:n=o.sent(),i.fileKey=n,i.fileType=P.BLOB,o.label=2;case 2:return e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&((t=e.scheduledInfo.scheduledMessageParams).file&&M(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,4];case 3:n=o.sent(),t.fileKey=n,t.fileType=P.BLOB,o.label=4;case 4:return[3,7];case 5:return e instanceof q&&((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;return s(this,(function(i){switch(i.label){case 0:return t.file&&M(t.file)?[4,this.collection.saveBlob(t.file,this._getFileInfoBlobKey(e.reqId,n))]:[3,2];case 1:r=i.sent(),t._uploadedMetaData||(t._uploadedMetaData={}),t._uploadedMetaData.fileKey=r,t._uploadedMetaData.fileType=P.BLOB,i.label=2;case 2:return[2]}}))}))})))]:[3,7];case 6:o.sent(),o.label=7;case 7:return[2]}}))}))},t}(h),de={},fe=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,de[t]=a,a}return u(t,e),t.of=function(e){return de[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return d(!!e).throw(l.databaseError),e.collection(B)},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)}),F.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,void 0]}}))}))},t.prototype.fetch=function(e){var t=e.channelUrl,n=e.token,i=e.limit,a=void 0===i?H:i,o=e.filter,c=void 0===o?new Q:o,u=e.order,l=void 0===u?W.CHANNEL_LATEST:u,h=e.backward,d=void 0!==h&&h,f=e.parentMessageId,_=e.isPollOnly,v=void 0!==_&&_,p=e.exactMatch,m=void 0!==p&&p,y=e.inclusive,E=void 0===y||y;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 W.CHANNEL_LATEST:if(m&&e.createdAt!==n)return!1;if(d){if(E&&e.createdAtn||!E&&e.createdAt>=n)return!1;break;case W.NEWEST_CHILD_MESSAGE:if(!f||0===e.parentMessageId||e.parentMessageId!==f)return!1}return!(v&&!e._poll)&&c.match(u._deserialize(e))}},index:e,backward:d},[4,this.collection.query(i)]):[3,3];case 1:return[4,h.sent().fetch({limit:null!=a?a:void 0})];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){return[2,this._deserialize(e)]}))}))})))];case 3:return[2,[]]}}))}))},t.prototype.getAllChildMessages=function(e,t){return void 0===t&&(t=new Q),r(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,this.fetch({channelUrl:e.channelUrl,token:Date.now(),limit:null,backward:!1,filter:t,order:W.NEWEST_CHILD_MESSAGE,parentMessageId:e.messageId})];case 1:return[2,n.sent()]}}))}))},t.prototype.upsert=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.localCacheEnabled?[4,this.saveBlobs(e)]:[3,5];case 1:return r.sent(),t=e.map((function(e){return n._serialize(e)})),[4,this.collection.upsertMany(t)];case 2:return r.sent(),[4,this.upsertChildMessages(e)];case 3:return r.sent(),[4,this._unsentMessageCache.upsertChildMessages(e)];case 4:r.sent(),r.label=5;case 5: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)&&e.threadInfo.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("".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(W.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(W.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(W.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&&M(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),_e=function(e){function t(t){var n=t.message,r=e.call(this)||this;return r.message=n,r}return u(t,e),t}(f),ve={},pe=function(){function e(e,t){var n=t.localCacheEnabled,r=t.dispatcher,i=t.sdkState,s=t.logger,a=this;this._iid=e,ve[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 p)switch(e.stateType){case m.CONNECTED:a._isProcessingAutoResend||a.processAutoResendRegisteredPendingMessages().then((function(){return a._processNextAutoResend()}));break;case m.INTERNAL_DISCONNECTED:case m.EXTERNAL_DISCONNECTED:a._isProcessingAutoResend=!1}}))}return e.of=function(e){return ve[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=_.FAILED,r.errorCode=y.ACK_TIMEOUT,this._dispatcher.dispatch(new E({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&&v(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=_.FAILED,this._dispatcher.dispatch(new E({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===_.SUCCEEDED||e.sendingStatus===_.FAILED&&!v(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=he.of(this._iid))?[4,e.fetch({sendingStatus:_.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 _e({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"}(te||(te={}));var me,ye=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 g(e,r),blockee:new g(e,i)}},e.getDataAsFriendDiscoveredEvent=function(e,t){var n=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(n)?n.map((function(t){return new g(e,t)})):[]}},e}(),Ee=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}(f);!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_BANNED="EVENT_CHANNEL_BANNED",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"}(me||(me={}));var be,ge=function(e){return e.startsWith("EVENT_")||e===me.SYNC_CHANNEL_CHANGELOGS||e===me.REFRESH_CHANNEL},Ne=function(e){function t(t){var n=t.channels,r=t.source,i=t.isWebSocketEventComing,s=void 0!==i&&i,a=t.data,o=void 0===a?null:a,c=e.call(this)||this;return c.channels=n,c.source=r,c.isWebSocketEventComing=s,c.data=o,c}return u(t,e),t}(f),Ie=function(e){function t(t){var n=t.channelUrls,r=t.source,i=t.isWebSocketEventComing,s=void 0!==i&&i,a=e.call(this)||this;return a.channelUrls=n,a.source=r,a.isWebSocketEventComing=s,a}return u(t,e),t}(f),we=function(e){function t(){return e.call(this)||this}return u(t,e),t}(f),Ae=function(e){function t(t,n,r){var i=e.call(this,t,"USEV",r)||this;return i.event=new ye(r),i}return u(t,e),t}(N),Te={},Oe=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,v=void 0!==_&&_;return Te[t]||(this.itemSizeLimit=r,this.cacheLimit=s,this.blockHashBase=o,this.blockHashMultiplier=u,this.blockHashConstant=h,this.transactionApplyDelay=f,this.disableLogger=v,Te[t]=this),Te[t]}return e.get=function(e){return Te[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 Ce,Se=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"}(Ce||(Ce={}));var Le,ke=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){if(t.has(e))throw Se.circularReferenceFound;t.set(e,!0);var n=void 0;if(Array.isArray(e))n=e.map((function(e){return ke(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]=ke(e[r],t);return t.delete(e),n}return e},Re=function(e,t){if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw Se.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},xe=function(e,t){for(var n=0,r=0;r>>0)%t},De=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Pe=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!Pe(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!Pe(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(!(Re(a,o)>0))return!1;break;case"/gte":case">=":a=t[r],o=i[s];if(!(Re(a,o)>=0))return!1;break;case"/lt":case"<":a=t[r],o=i[s];if(!(Re(a,o)<0))return!1;break;case"/lte":case"<=":a=t[r],o=i[s];if(!(Re(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)},Me=function(){},Be=function(){return Promise.resolve()},He=function(e){return e},Ue=function(e,t){t()};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Le||(Le={}));var Ve,Ke,qe,Fe=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?He:a,c=e.backward,u=void 0===c?Be:c,l=e.forward,h=void 0===l?Be:l,d=e.complete,f=void 0===d?Me: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}(),je=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*Re(this._indexer.origin[u].columnValues[i],this.condition[s][c])<=0){r=u;break}}else for(u=r;u>=0;u--)if(a*Re(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===qe.PERSISTENT&&(r.state=Ke.PERSISTENT),t!==qe.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)$e.includes(this._items[r].state)&&$e.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}(),nt=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(We(e,t),"/trans.metadata")}(t,n),this.recordsetKey=function(e,t){return"".concat(We(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,I([],w(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=tt.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=tt.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=rt.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=Oe.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,tt.get(this.dbname).find(this._store,r)];case 1:return a=s.sent(),(null==(o=a?rt.createFromCacheItem(a):new rt({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=Qe(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(),tt.get(this.dbname).clearByCondition((function(t){return t.key.startsWith(e)})),[2]}}))}))},e}(),st={},at=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(We(e,t),"/index.").concat(n)}(t,n,i.join(">"));return st[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()}))),st[c]}return e.createKey=function(e){return e.join(">")},e.parseKey=function(e){return e.split(">")},e.clearIndexerMap=function(){for(var e in st)delete st[e]},e.prototype._addItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=w(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=w(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 Se.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=Re(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,_,v,p,m,y;return s(this,(function(s){switch(s.label){case 0:return[4,(e=tt.get(this.dbname)).find(this._store,this.indexerKey,qe.PERSISTENT)];case 1:return(t=s.sent())?[3,11]:(n=Qe(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,qe.NO_CACHE)]:[3,6];case 5:if(u=s.sent(),l=rt.createFromCacheItem(u))try{for(m=void 0,h=i(l.items),d=h.next();!d.done;d=h.next())f=d.value,this._addItem(f)}catch(e){m={error:e}}finally{try{d&&!d.done&&(y=h.return)&&y.call(h)}finally{if(m)throw m.error}}s.label=6;case 6:return o=a.next(),[3,4];case 7:return[3,10];case 8:return _=s.sent(),v={error:_},[3,10];case 9:try{o&&!o.done&&(p=a.return)&&p.call(a)}finally{if(v)throw v.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=ke(this._origin),s.label=12;case 12:return st[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 tt.get(this.dbname).remove(this.indexerKey),[4,this._store.remove(this.indexerKey)];case 1:return e.sent(),delete st[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=ke(this._origin)},e.prototype.abort=function(){this._table=ke(this._origin)},e}(),ot=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=Ce.INIT,this._indexers=[],this.dbname=t,this.name=n,this.keyName=r,this.indexes=I([[r]],w(s.filter((function(e){return at.createKey(e)!==o.keyName}))),!1),this._keyHash=i,this._store=a,this._mutex=new re(function(e,t){return"".concat(We(e,t),".lock")}(t,n)),this._blobContainer=new Ze({dbname:t,collectionName:n,store:a}),this._transaction=new nt({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=Ye(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===Ce.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,_,v,p,m=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=Oe.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 it({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),r=I([],w(this.indexes),!1),a=[],o=r.map((function(e){return at.createKey(e)})),c=n?n.indexes.map((function(e){return at.createKey(e)})):[];try{for(u=i(c),l=u.next();!l.done;l=u.next())h=l.value,o.includes(h)||a.push(at.parseKey(h))}catch(e){v={error:e}}finally{try{l&&!l.done&&(p=u.return)&&p.call(u)}finally{if(v)throw v.error}}return(d=[]).push.apply(d,I([],w(r.map((function(e){var t=new at({dbname:m.dbname,collectionName:m.name,keyName:m.keyName,fields:e,transaction:m._transaction,store:m._store});return m._indexers.push(t),t.ensure()}))),!1)),d.push.apply(d,I([],w(a.map((function(e){return new at({dbname:m.dbname,collectionName:m.name,keyName:m.keyName,fields:e,transaction:m._transaction,store:m._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=Ye(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=Ce.READY,this._mutex.unlock(),[3,10];case 9:throw _=s.sent(),this._mutex.unlock(),_;case 10:return[2]}}))}))},e.prototype.close=function(){this._state=Ce.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=at.createKey(e);try{for(var s=i(this._indexers),a=s.next();!a.done;a=s.next()){var o=a.value;if(r===at.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 Se.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=Ye(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 Se.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,_,v;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&&(v=c.return)&&v.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,ke(t)];case 4:throw n=r.sent(),this._mutex.unlock(),n;case 5:return[3,7];case 6:throw Se.collectionNotReady;case 7:return[2]}}))}))},e.prototype.query=function(e){if(void 0===e&&(e={}),this.isReady)return new Ge({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Se.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 Se.collectionKeyNotGiven;return[4,this._requestInsert(ke(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 Se.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 Se.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(ke(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 Se.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 Se.collectionKeyNotGiven;return[4,this._requestUpsert(ke(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 Se.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 Se.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(ke(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 Se.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 Se.collectionKeyNotGiven;return[4,this._requestUpdate(ke(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 Se.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,_,v,p,m,y,E=this;return s(this,(function(b){switch(b.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,16];case 1:b.sent(),b.label=2;case 2:return b.trys.push([2,13,,15]),n=e.where,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 je({condition:a,blockManager:this._blockManager,backward:l,indexer:this._getIndexerBy(c)}).each((function(e){return r(E,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,Pe(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:b.sent(),b.label=4;case 4:b.trys.push([4,9,10,11]),d=i(h),f=d.next(),b.label=5;case 5:return f.done?[3,8]:(_=f.value,[4,this._requestUpdate(ke(_))]);case 6:b.sent(),b.label=7;case 7:return f=d.next(),[3,5];case 8:return[3,11];case 9:return v=b.sent(),m={error:v},[3,11];case 10:try{f&&!f.done&&(y=d.return)&&y.call(d)}finally{if(m)throw m.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return b.sent(),this._mutex.unlock(),[2,h];case 13:return p=b.sent(),[4,this._transaction.clear()];case 14:throw b.sent(),this._mutex.unlock(),p;case 15:return[3,17];case 16:throw this._transaction.clear(),Se.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 Se.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,_,v,p,m,y=this;return s(this,(function(E){switch(E.label){case 0:return this.isReady?[4,this._mutex.lock()]:[3,15];case 1:E.sent(),E.label=2;case 2:return E.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 je({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,Pe(n,t)&&(r=t[this.keyName],l.push(r)),e.next()):e.stop(),[2]}))}))}))];case 3:E.sent(),E.label=4;case 4:E.trys.push([4,9,10,11]),h=i(l),d=h.next(),E.label=5;case 5:return d.done?[3,8]:(f=d.value,[4,this._requestRemove(f)]);case 6:E.sent(),E.label=7;case 7:return d=h.next(),[3,5];case 8:return[3,11];case 9:return _=E.sent(),p={error:_},[3,11];case 10:try{d&&!d.done&&(m=h.return)&&m.call(h)}finally{if(p)throw p.error}return[7];case 11:return[4,this._transaction.commit()];case 12:return E.sent(),this._mutex.unlock(),[2,l];case 13:throw v=E.sent(),this._mutex.unlock(),v;case 14:return[3,16];case 15:throw this._transaction.clear(),Se.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 Se.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}(),ct=function(){function e(e){var t,n,r;this.encryption=null!==(t=e.encryption)&&void 0!==t?t:A,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),I([],w(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 Se.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,I([],w(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,I([],w(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}(),ut={},lt=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 ut[this.dbname]},set:function(e){ut[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(ut[this.dbname])return[2,Object.keys(ut[this.dbname])];throw Se.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 ut[this.dbname]?[4,De(this.delay)]:[3,2];case 1:return t.sent(),[2,ut[this.dbname][e]?a({key:e},ut[this.dbname][e]):null];case 2:throw Se.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 ut[this.dbname]?[4,De(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,ut[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 Se.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 ut[this.dbname]?[4,De(this.delay)]:[3,2];case 1:s.sent();try{for(t=i(e),n=t.next();!n.done;n=t.next())r=n.value,ut[this.dbname][r]&&delete ut[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 Se.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,ut[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,De(this.delay)];case 1:return e.sent(),ut[this.dbname]={},[2]}}))}))},t}(ct),ht="NestDBStore";!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(Xe||(Xe={}));var dt=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=ht,r._state=Xe.UNINITIALIZED,r._openJobQueue=[],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),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),t.prototype._openDatabase=function(e){var t=this;return new Promise((function(n,r){if(t._indexedDb){t._state=Xe.OPENING;var i=t._indexedDb.open(e);i.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(ht,{keyPath:"key"})})),i.addEventListener("success",(function(r){t._state=Xe.OPEN,t._database=r.target.result,t._openJobQueue.forEach((function(e){return e()})),t._openJobQueue=[],t._database.onclose=function(){t._database=void 0,t._state=Xe.OPENING,setTimeout((function(){t._openDatabase(e)}),5)},n(t._database)})),i.addEventListener("error",(function(e){t._state=Xe.UNINITIALIZED,r(e.target.error)}))}else r(Se.storeNotAvailable)}))},t.prototype._getObjectStore=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._database?[2,this._database.transaction(this._storeName,e).objectStore(this._storeName)]:[3,1];case 1:switch(this._state){case Xe.UNINITIALIZED:case Xe.OPEN:return[3,2];case Xe.OPENING:case Xe.CLOSED:return[3,3]}return[3,4];case 2:throw Se.storeNotInitialized;case 3:return[2,new Promise((function(n){t._openJobQueue.push((function(){return n(t._getObjectStore(e))}))}))];case 4:return[4,this._getObjectStore(e)];case 5:return[2,n.sent()]}}))}))},t.prototype._getAllRawKeys=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return[4,this._getObjectStore("readonly")];case 1:return e=t.sent(),[4,new Promise((function(t,n){var r=e.getAllKeys();r.addEventListener("success",(function(e){t(e.target.result)})),r.addEventListener("error",(function(e){return n(e.target.error)}))}))];case 2:return[2,t.sent()]}}))}))},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._getObjectStore("readonly")];case 1:return t=n.sent(),[4,new Promise((function(n,r){var i=t.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 2: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[4,this._getObjectStore("readwrite")];case 1:return t=n.sent(),[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 2: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[4,this._getObjectStore("readwrite")];case 1:return t=n.sent(),[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 2:return n.sent(),[2]}}))}))},t.prototype._triggerDatabaseClose=function(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))},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||!$())return[3,4];if(!($()&&navigator.userAgent&&navigator.userAgent.includes("Edge/")))return[3,1];if(!this._window.indexedDB&&(e.PointerEvent||e.MSPointerEvent))throw Se.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(Se.storeNotAvailableInPrivateBrowsing)},r.onsuccess=function(){return e()}}catch(e){n(Se.storeNotAvailableInPrivateBrowsing)}else n(Se.storeNotAvailable)}))];case 2:n.sent(),n.label=3;case 3:return[3,5];case 4:throw Se.storeNotAvailable;case 5:return[3,7];case 6:throw Se.storeNotAvailable;case 7:return[2]}}))}))},t.prototype.init=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return this.dbname=e,[4,this.checkAvailability()];case 1:return t.sent(),[4,this._openDatabase(e)];case 2:return t.sent(),[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._getObjectStore("readwrite")];case 1:return e=t.sent(),[4,new Promise((function(t,n){var r=e.clear();r.addEventListener("success",(function(){return t()})),r.addEventListener("error",(function(e){return n(e.target.error)}))}))];case 2:return[2,t.sent()]}}))}))},t}(ct),ft=function(e){function t(t){var n=this,r=t.AsyncStorage,i=t.itemSizeLimit,s=void 0===i?6291456:i,o=T(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 Se.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}(ct);!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 Se.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]}}))}))}}(ct);var _t,vt="[NESTDB]",pt=!0,mt=function(){function e(){}return e.off=function(){pt=!1},e.log=function(){for(var e=[],t=0;t0&&e.maxHeight>0})))},ke=function(e){return o({fileInfoList:e.fileInfoList,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption})},Qe=s(s({},Se),{fileInfoList:[]}),ze=function(e){return(c(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"}(Re||(Re={}));var xe,Ge=function(){function e(e){var t,r,i,a;this.restrictionType=null,n(Re,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 o(u({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt,remaining_duration:e.remainingDuration}))},e}(),Ve=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.restrictionInfo=new Ge(n),r}return d(t,e),t.payloadify=function(t){return o(u(s(s({},e.payloadify.call(this,t)),Ge.payloadify(t.restrictionInfo))))},t}(i),je={data:void 0,customType:void 0,mentionType:e.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,mentionedMessageTemplate:void 0,metaArrays:void 0,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0},Be=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(J,s.metaArrays,!0)&&n(a,s.pushNotificationDeliveryOption,!0)&&t(X,s.appleCriticalAlertOptions,!0)},We=s(s({},je),{message:void 0,translationTargetLanguages:void 0,pollId:void 0}),Ke=function(e){return Be(e)&&t("string",e.message,!0)&&r("string",e.translationTargetLanguages,!0)&&t("number",e.pollId,!0)},He=s({},je),Ye=function(e){function t(t){var n=t.channelUrl,r=t.channelType,i=t.token,a=t.limit,s=e.call(this)||this;return s.method=h.GET,s.path="".concat(p(r),"/").concat(encodeURIComponent(n),"/operators"),s.params={token:i,limit:a},s}return d(t,e),t}(f),Je=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.operators=n.operators.map((function(e){return new i(t,e)})),r.token=n.next,r}return d(t,e),t}(m),Xe=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return d(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return v(this,void 0,void 0,(function(){var e,t,n,r,i,a,o;return g(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=T.of(this._iid).requestQueue,n=new Ye(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(Je),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 _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},t}(y),Ze=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.limit,s=t.token;return(n=e.call(this)||this).method=h.GET,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/mute"),n.params={limit:a,token:s},n}return d(t,e),t}(f),$e=function(e){function t(t,n){var r=e.call(this,t,n)||this;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 Ve(t,e)}))),r}return d(t,e),t}(m),et=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return d(t,e),t.prototype.next=function(){return v(this,void 0,void 0,(function(){var e,t,n,r,i,a;return g(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=T.of(this._iid).requestQueue,t=new Ze(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as($e),i=r.mutedUsers,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},t}(y),tt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.limit,s=t.token;return(n=e.call(this)||this).method=h.GET,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/ban"),n.params=o({limit:a,token:s}),n}return d(t,e),t}(f),nt=function(e){function t(t,n){var r=e.call(this,t,n)||this;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 Ve(t,e.user)}))),r}return d(t,e),t}(m),rt=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return d(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return v(this,void 0,void 0,(function(){var e,t,n,r,i,a;return g(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=T.of(this._iid).requestQueue,t=new tt(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(nt),i=r.bannedUsers,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},t}(y);!function(e){e.SPAM="spam",e.HARASSING="harassing",e.SUSPICIOUS="suspicious",e.INAPPROPRIATE="inappropriate"}(xe||(xe={}));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=h.POST,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var at=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return d(t,e),t}(f);!function(e){function t(t,n){return e.call(this,t,n)||this}d(t,e)}(m);var st=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=h.GET,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/mute/").concat(a),n}return d(t,e),t}(f),ot=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.isMuted=!1,r.startAt=0,r.endAt=0;var i=n.is_muted,a=n.start_at,s=n.end_at,o=n.remaining_duration,u=n.description;return r.isMuted=i,r.startAt=a,r.endAt=s,r.remainingDuration=o,r.description=u,r}return d(t,e),t}(m),ut=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.keys;return(n=e.call(this)||this).method=h.GET,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={keys:a,include_ts:!0},n}return d(t,e),t}(f),ct=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.metadata,a=n.ts;return r.metadata=i,r.ts=a,r}return d(t,e),t}(m),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=h.POST,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0},n}return d(t,e),t}(f),dt=function(e){function t(t,n){var r,i,a=this;return(a=e.call(this,t,n)||this).metaData=null!==(r=n.metadata)&&void 0!==r?r:{},a.ts=null!==(i=n.ts)&&void 0!==i?i:null,a}return d(t,e),t}(m),ht=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metadata,s=t.upsert;return(n=e.call(this)||this).method=h.PUT,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0,upsert:null!=s&&s},n}return d(t,e),t}(f),pt=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.metadata,a=n.ts;return r.metadata=i,r.ts=a,r}return d(t,e),t}(m),ft=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return r.data&&(i.created=r.data.created,i.updated=r.data.updated,i.deleted=r.data.deleted),i}return d(t,e),t}(U),mt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.key;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metadata/").concat(a),n.params={include_ts:!0},n}return d(t,e),t}(f),vt=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.ts;return r.ts=i,r}return d(t,e),t}(m),yt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={include_ts:!0},n}return d(t,e),t}(f),gt=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.ts;return r.ts=i,r}return d(t,e),t}(m),_t=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.keys;return(n=e.call(this)||this).method=h.GET,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={keys:a},n}return d(t,e),t}(f),Tt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return d(t,e),t}(m),Ut=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metaCounter;return(n=e.call(this)||this).method=h.POST,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a},n}return d(t,e),t}(f),It=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return d(t,e),t}(m),wt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metaCounter,s=t.upsert,o=void 0!==s&&s,u=t.mode,c=void 0===u?"set":u;return(n=e.call(this)||this).method=h.PUT,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a,upsert:o,mode:c},n}return d(t,e),t}(f),Mt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return d(t,e),t}(m),Et=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return r.data&&(i.created=r.data.created,i.updated=r.data.updated,i.deleted=r.data.deleted),i}return d(t,e),t}(U),bt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.key;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metacounter/").concat(a),n.params={},n}return d(t,e),t}(f);!function(e){function t(t,n){return e.call(this,t,n)||this}d(t,e)}(m);var St=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={},n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var Pt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId,s=t.seconds,o=t.description;return(n=e.call(this)||this).method=h.POST,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/mute"),n.params={user_id:a,seconds:s,description:o},n}return d(t,e),t}(f);!function(e){function t(t,n){return e.call(this,t,n)||this}d(t,e)}(m);var Ct=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ve(t,r.data),i}return d(t,e),t}(U),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=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/mute/").concat(encodeURIComponent(a)),n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var Dt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ve(t,r.data),i}return d(t,e),t}(U),Rt=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=h.POST,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/ban"),n.params=o({user_id:a,seconds:s,description:u}),n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var qt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ve(t,r.data),r.data.member_count&&(i.memberCount=r.data.member_count),r.data.joined_member_count&&(i.joinedMemberCount=r.data.joined_member_count),i}return d(t,e),t}(U),Ot=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/ban/").concat(encodeURIComponent(a)),n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var Lt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ve(t,r.data),i}return d(t,e),t}(U),Nt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.freezing;return(n=e.call(this)||this).method=h.PUT,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/freeze"),n.params={freeze:a},n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var Ft=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.freeze=r.data.freeze,i}return d(t,e),t}(U),kt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.category,s=t.userId,o=t.description;return(n=e.call(this)||this).method=h.POST,n.path="".concat(I(i),"/").concat(encodeURIComponent(r)),n.params={report_category:a,reporting_user_id:s,report_description:o},n}return d(t,e),t}(f),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.description;return(n=e.call(this)||this).method=h.POST,n.path="".concat(w,"/users/").concat(o),n.params={channel_url:r,channel_type:i===M.OPEN?"open_channels":"group_channels",report_category:a,reporting_user_id:s,report_description:u},n}return d(t,e),t}(f),zt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.category,s=t.userId,o=t.offendingUserId,u=t.messageId,c=t.description;return(n=e.call(this)||this).method=h.POST,n.path="".concat(I(i),"/").concat(encodeURIComponent(r),"/messages/").concat(u),n.params={report_category:a,reporting_user_id:s,report_description:c,offending_user_id:o},n}return d(t,e),t}(f),xt=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(u({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?n.parentMessageId:null,req_id:n.reqId,poll_id:n.pollId,pin_message:n.isPinnedMessage}))})||this}return d(n,t),n}(E),Gt=function(e){function t(t,n,r){var i,a,s,o,u=this;(u=e.call(this,t,"MESG",r)||this).message=new Z(t,r);var c=T.of(t).sdkState;return u.isMentioned=b(u.message.mentionType,null!==(s=null!==(i=u.message.mentionedUserIds)&&void 0!==i?i:null===(a=u.message.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})))&&void 0!==s?s:[],c.userId),u.forceUpdateLastMessage=null!==(o=r.force_update_last_message)&&void 0!==o&&o,u}return d(t,e),t}(U),Vt=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:"MEDI",ackRequired:!0,payload:o(u({channel_url:n.channelUrl,msg_id:n.messageId,message:n.message,data:n.data,custom_type:n.customType,metaarray:n.metaArrayParams,mention_type:n.mentionType,mentioned_user_ids:r,mentioned_message_template:n.mentionedMessageTemplate,apple_critical_alert_options:n.appleCriticalAlertOptions?X.payloadify(n.appleCriticalAlertOptions):null,poll_id:n.pollId}))})||this}return d(n,t),n}(E),jt=function(e){function t(t,n,r){var i,a,s,o,c,l=this;(l=e.call(this,t,"MEDI",r)||this).message=new Z(t,r);var d=T.of(t).sdkState;return l.mentionCountChange=S({mentionType:null===(i=r.old_values)||void 0===i?void 0:i.mention_type,mentionedUserIds:null!==(s=null===(a=r.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==s?s:[]},u({mentionType:l.message.mentionType,mentionedUserIds:null!==(o=l.message.mentionedUserIds)&&void 0!==o?o:null===(c=l.message.mentionedUsers)||void 0===c?void 0:c.map((function(e){return e.userId}))}),d.userId),l}return d(t,e),t}(U),Bt=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(u({channel_url:n.channelUrl,msg_id:n.messageId,data:n.data,custom_type:n.customType,metaarray:n.metaArrayParams,mention_type:n.mentionType,mentioned_user_ids:r,apple_critical_alert_options:n.appleCriticalAlertOptions}))})||this}return d(n,t),n}(E),Wt=function(e){function t(t,n,r){var i,a,s,o,c,l=this;(l=e.call(this,t,"FEDI",r)||this).message=new $(t,r);var d=T.of(t).sdkState;return l.mentionCountChange=S({mentionType:null===(i=r.old_values)||void 0===i?void 0:i.mention_type,mentionedUserIds:null!==(s=null===(a=r.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==s?s:[]},u({mentionType:l.message.mentionType,mentionedUserIds:null!==(o=l.message.mentionedUserIds)&&void 0!==o?o:null===(c=l.message.mentionedUsers)||void 0===c?void 0:c.map((function(e){return e.userId}))}),d.userId),l}return d(t,e),t}(U),Kt=function(e){function t(t){var n=e.call(this)||this;return n.method=h.DELETE,n.path="".concat(p(t.channelType),"/").concat(t.channelUrl,"/messages/").concat(t.messageId),n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var Ht=function(e){function t(t,n,r){var i=e.call(this,t,"DELM",r)||this;return i.channelUrl=r.channel_url,i.channelType=r.channel_type,i.messageId=Number(r.msg_id),i}return d(t,e),t}(U),Yt=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.reactionKey,s=e.call(this)||this;return s.method=h.POST,s.path="".concat(p(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/reactions"),s.params={reaction:a},s}return d(t,e),t}(f),Jt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new ee(n),r}return d(t,e),t}(m),Xt=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.reactionKey,s=e.call(this)||this;return s.method=h.DELETE,s.path="".concat(p(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/reactions"),s.params={reaction:a},s}return d(t,e),t}(f),Zt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new ee(s({},n)),r}return d(t,e),t}(m),$t=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.translationTargetLanguages,s=e.call(this)||this;return s.method=h.POST,s.path="".concat(p(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i),"/translation"),s.params={target_langs:a},s}return d(t,e),t}(f),en=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new Z(t,n),r}return d(t,e),t}(m),tn=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,c=n.channelUrl;return i.method=h.POST,i.path="".concat(p(s),"/").concat(encodeURIComponent(c),"/scheduled_messages"),i.params=o(u({req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:P.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 J.payloadify(e)})),apple_critical_alert_options:n.appleCriticalAlertOptions?X.payloadify(n.appleCriticalAlertOptions):null,target_langs:n.translationTargetLanguages,push_option:n.pushNotificationDeliveryOption})),i}return d(n,t),n}(f),nn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new Z(t,n),r}return d(t,e),t}(m),rn=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=h.POST,i.path="".concat(p(s),"/").concat(encodeURIComponent(o),"/scheduled_messages"),i.params=u({req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:P.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 te.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 J.payloadify(e)})),apple_critical_alert_options:n.appleCriticalAlertOptions?X.payloadify(n.appleCriticalAlertOptions):null,push_option:n.pushNotificationDeliveryOption}),i}return d(n,t),n}(f),an=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new $(t,n),r}return d(t,e),t}(m),sn=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=h.PUT,u.path="".concat(A,"/").concat(encodeURIComponent(n)),u.params={title:r,data:i,allow_user_suggestion:a,allow_multiple_votes:s,close_at:o},u}return d(t,e),t}(f),on=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new D(t,n),r}return d(t,e),t}(m),un=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=h.DELETE,r.path="".concat(A,"/").concat(encodeURIComponent(n)),r}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var cn=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=h.PUT,r.path="".concat(A,"/").concat(encodeURIComponent(n),"/close"),r}return d(t,e),t}(f),ln=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new D(t,n),r}return d(t,e),t}(m),dn=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=h.POST,s.path="".concat(A,"/").concat(encodeURIComponent(i),"/options"),s.params={channel_url:n,channel_type:r,text:a},s}return d(t,e),t}(f),hn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new D(t,n),r}return d(t,e),t}(m),pn=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,i=t.optionText,a=e.call(this)||this;return a.method=h.PUT,a.path="".concat(A,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),a.params={text:i},a}return d(t,e),t}(f),fn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new D(t,n),r}return d(t,e),t}(m),mn=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,i=e.call(this)||this;return i.method=h.DELETE,i.path="".concat(A,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),i}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var vn=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===M.OPEN?"open_channels":"group_channels",channel_url:i,poll_id:a,option_ids:s})})||this}return d(t,e),t}(E),yn=function(e){function t(t,n,r){var i=e.call(this,t,"VOTE",r)||this;return i.event=new fe(r),i.channelUrl=r.channel_url,i.channelType=r.channel_type,i}return d(t,e),t}(U),gn=2,_n=function(e){function h(n,r){var a,s,o,u,c=this;return(c=e.call(this,n)||this).channelType=M.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 d(h,e),h.payloadify=function(t){return o(u(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:t.creator?i.payloadify(t.creator):null,created_at:t.createdAt/1e3})))},h.prototype.isGroupChannel=function(){return this.channelType===M.GROUP},h.prototype.isOpenChannel=function(){return this.channelType===M.OPEN},Object.defineProperty(h.prototype,"cachedMetaData",{get:function(){var e={};return this._cachedMetaData?(this._cachedMetaData.forEach((function(t,n){t.isRemoved||(e[n]=t.value)})),e):e},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"messageCollectionLastAccessedAt",{get:function(){return this._messageCollectionLastAccessedAt},enumerable:!1,configurable:!0}),h.prototype._updateMessageCollectionLastAccessedAt=function(){this._messageCollectionLastAccessedAt=Date.now()},h.prototype._update=function(e){var t=o(e);Object.assign(this,t)},h.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})}))},h.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(_.invalidParameters),n=T.of(this._iid).requestQueue,i=new $t({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),[4,n.send(i)];case 1:return a=s.sent(),[2,a.as(en).message]}}))}))},h.prototype._createScheduledUserMessage=function(e,t){var n=this,r=T.of(this._iid).requestQueue,i=Date.now(),a=this._generateRequestId();Q(2).then((function(){var r=n._createPendingScheduledUserMessage(e,a,i);G((function(){return v(n,void 0,void 0,(function(){return g(this,(function(e){return[2,t._trigger(null,r)]}))}))}))}));var o=new tn(s({reqId:a,channelType:this.channelType,channelUrl:this.url},e));r.send(o).then((function(e){var r=e.as(nn).message;G((function(){return v(n,void 0,void 0,(function(){return g(this,(function(e){return[2,t._trigger(null,r)]}))}))}))})).catch((function(r){if(V(r))throw r;Q(2).then((function(){var s=n._createPendingScheduledUserMessage(e,a,i);n._markMessageAsFailed(s,r),G((function(){return v(n,void 0,void 0,(function(){return g(this,(function(e){return[2,t._trigger(r,s)]}))}))}))}))}))},h.prototype.sendFileMessage=function(e){var t=s(s({},Ne),e);return k(Fe(t)).throw(_.invalidParameters),this._sendFileMessage(t)},h.prototype.sendMultipleFilesMessage=function(e){var t,n=s(s({},Qe),e),r=T.of(this._iid);k(function(e,t){return void 0===t&&(t=l),Pe(e)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=t&&e.fileInfoList.every((function(e){return ze(e)}))}(n,null===(t=r.appInfo)||void 0===t?void 0:t.multipleFilesMessageFileCountLimit)).throw(_.invalidParameters);var i=!!e.fileInfoList.find((function(e){var t=r.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return k(!i).throw(_.fileSizeLimitExceededError),this._sendMultipleFilesMessage(n)},h.prototype._sendFileMessage=function(e,t){var n=this,r=T.of(this._iid),i=r.dispatcher;r.sessionManager;var a=ae.of(this._iid).fileMessageQueue,s=null!=t?t:this._generateRequestId(),o=Date.now(),u=new oe;return Q(2).then((function(){var t=n._createPendingFileMessage(e,s,o);i.dispatch(new z({messages:[t],source:x.EVENT_MESSAGE_SENT_PENDING})),G((function(){return v(n,void 0,void 0,(function(){return g(this,(function(e){return[2,u._trigger(null,t)]}))}))})),a.request(n,s,e).then((function(e){i.dispatch(new z({messages:[e],source:x.EVENT_MESSAGE_SENT_SUCCESS})),G((function(){return v(n,void 0,void 0,(function(){return g(this,(function(t){return[2,u._trigger(null,e)]}))}))}))})).catch((function(t){if(V(t))throw t;var r=n._createPendingFileMessage(e,s,o),a=T.of(n._iid).cacheContext.localCacheEnabled&&j(t.code);n._markMessageAsFailed(r,t,a),i.dispatch(new z({messages:[r],source:r.sendingStatus===O.PENDING?x.REQUEST_RESEND_MESSAGE:x.EVENT_MESSAGE_SENT_FAILED})),G((function(){return v(n,void 0,void 0,(function(){return g(this,(function(e){return[2,u._trigger(t,r)]}))}))}))}))})),u},h.prototype._autoResendFileMessage=function(e){k(e instanceof $&&!!e.messageParams).throw(_.invalidParameters);var t=T.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))},h.prototype._sendMultipleFilesMessage=function(e,t){var n=this,r=T.of(this._iid),i=r.dispatcher;r.sessionManager;var a=ae.of(this._iid).fileMessageQueue,s=null!=t?t:this._generateRequestId(),o=Date.now(),u=new se;return Q(2).then((function(){var t=n._createPendingMultipleFilesMessage(e,s,o);i.dispatch(new z({messages:[t],source:x.EVENT_MESSAGE_SENT_PENDING})),G((function(){return v(n,void 0,void 0,(function(){return g(this,(function(e){return[2,u._trigger(null,t)]}))}))})),a.request(n,s,e,u).then((function(e){i.dispatch(new z({messages:[e],source:x.EVENT_MESSAGE_SENT_SUCCESS})),G((function(){return v(n,void 0,void 0,(function(){return g(this,(function(t){return[2,u._trigger(null,e)]}))}))}))})).catch((function(t){if(V(t))throw t;var r=n._createPendingMultipleFilesMessage(e,s,o);n._markMessageAsFailed(r,t),i.dispatch(new z({messages:[r],source:x.EVENT_MESSAGE_SENT_FAILED})),G((function(){return v(n,void 0,void 0,(function(){return g(this,(function(e){return[2,u._trigger(t,r)]}))}))}))}))})),u},h.prototype._createScheduledFileMessage=function(e,t,n,r){var i=this,a=T.of(this._iid).requestQueue,o=new rn(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(an).message;G((function(){return v(i,void 0,void 0,(function(){return g(this,(function(e){return[2,t._trigger(null,n)]}))}))}))})).catch((function(a){if(V(a))throw a;Q(2).then((function(){var s=i._createPendingScheduledFileMessage(e,n,r);i._markMessageAsFailed(s,a),G((function(){return v(i,void 0,void 0,(function(){return g(this,(function(e){return[2,t._trigger(a,s)]}))}))}))}))}))},h.prototype.sendFileMessages=function(e){var t,n;k(e.every((function(e){return Fe(s(s({},Ne),e))}))).throw(_.invalidParameters);var r=new oe;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},h.prototype.resendFileMessage=function(e,t){var n;return v(this,void 0,void 0,(function(){var r,i,a;return g(this,(function(s){return r=Boolean(e.url)||c(t)||c(null===(n=e.messageParams)||void 0===n?void 0:n.file),k(e instanceof $&&r&&!e.scheduledInfo).throw(_.invalidParameters),i=new H,a=function(e,t){var n;return e.messageParams?(!e.url&&c(t)&&(e.messageParams.file=t),e.messageParams):o(u({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,file:t,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:null===(n=e.thumbnails)||void 0===n?void 0:n.map((function(e){return{maxWidth:e.width,maxHeight:e.height}}))}))}(e,t),this._sendFileMessage(a,e.reqId).onFailed((function(e){return i.reject(e)})).onSucceeded((function(e){return i.resolve(e)})),[2,i.promise]}))}))},h.prototype.updateFileMessage=function(e,n){return v(this,void 0,void 0,(function(){var r,i,a,o;return g(this,(function(u){switch(u.label){case 0:return r=s(s({},He),n),k(t("number",e)&&function(e){return Be(e)}(r)).throw(_.invalidParameters),i=T.of(this._iid).requestQueue,a=new Bt(s({channelType:this.channelType,channelUrl:this.url,messageId:e},r)),[4,i.send(a)];case 1:return o=u.sent(),[2,o.as(Wt).message]}}))}))},h.prototype.cancelUploadingFileMessage=function(e){return v(this,void 0,void 0,(function(){return g(this,(function(n){return k(t("string",e)).throw(_.invalidParameters),ae.of(this._iid).fileMessageQueue.cancel(this,e),[2,!0]}))}))},h.prototype.copyFileMessage=function(e,t){var n,r,i;return v(this,void 0,void 0,(function(){var o,c;return g(this,(function(l){return k(e instanceof h&&t instanceof $&&t.sendingStatus===O.SUCCEEDED&&this.url===t.channelUrl&&!t.scheduledInfo).throw(_.invalidParameters),o=new H,c=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(c).onSucceeded((function(e){return o.resolve(e)})).onFailed((function(e){return o.reject(e)})),[2,o.promise]}))}))},h.prototype.deleteMessage=function(e){return v(this,void 0,void 0,(function(){var t,n;return g(this,(function(r){switch(r.label){case 0:return k(e instanceof he).throw(_.invalidParameters),e.messageId>0?(t=T.of(this._iid).requestQueue,n=new Kt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId}),[4,t.send(n)]):[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}}))}))},h.prototype.addReaction=function(e,n){return v(this,void 0,void 0,(function(){var r,i,a;return g(this,(function(s){switch(s.label){case 0:return k(e instanceof he&&e.messageId>0&&t("string",n)).throw(_.invalidParameters),r=T.of(this._iid).requestQueue,i=new Yt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(Jt).reactionEvent]}}))}))},h.prototype.deleteReaction=function(e,n){return v(this,void 0,void 0,(function(){var r,i,a;return g(this,(function(s){switch(s.label){case 0:return k(e instanceof he&&e.messageId>0&&t("string",n)).throw(_.invalidParameters),r=T.of(this._iid).requestQueue,i=new Xt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(Zt).reactionEvent]}}))}))},h.prototype._updateUserMessageMetaArray=function(e,t,n,r){return v(this,void 0,void 0,(function(){var i,a,s,o,u,c;return g(this,(function(l){switch(l.label){case 0:return i=T.of(this._iid),a=i.dispatcher,s=i.requestQueue,o=new Vt({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(jt).message,a.dispatch(new z({messages:[c],source:x.EVENT_MESSAGE_UPDATED})),[2,c]}}))}))},h.prototype._updateFileMessageMetaArray=function(e,t,n,r){return v(this,void 0,void 0,(function(){var i,a,s,o,u,c;return g(this,(function(l){switch(l.label){case 0:return i=T.of(this._iid),a=i.dispatcher,s=i.requestQueue,o=new Bt({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(Wt).message,a.dispatch(new z({messages:[c],source:x.EVENT_MESSAGE_UPDATED})),[2,c]}}))}))},h.prototype.createMessageMetaArrayKeys=function(e,t){return v(this,void 0,void 0,(function(){var n;return g(this,(function(i){return k(e instanceof he&&e.messageId>0&&r("string",t)).throw(_.invalidParameters),n=t.map((function(e){return new J({key:e})})),e instanceof $?[2,this._updateFileMessageMetaArray(e.messageId,n,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"add",!0)]}))}))},h.prototype.deleteMessageMetaArrayKeys=function(e,t){return v(this,void 0,void 0,(function(){var n;return g(this,(function(i){return k(e instanceof he&&e.messageId>0&&r("string",t)).throw(_.invalidParameters),n=t.map((function(e){return new J({key:e})})),e instanceof $?[2,this._updateFileMessageMetaArray(e.messageId,n,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"remove",!0)]}))}))},h.prototype.addMessageMetaArrayValues=function(e,t){return v(this,void 0,void 0,(function(){return g(this,(function(n){return k(e instanceof he&&e.messageId>0&&t.every((function(e){return e instanceof J}))).throw(_.invalidParameters),e instanceof $?[2,this._updateFileMessageMetaArray(e.messageId,t,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"add",!0)]}))}))},h.prototype.removeMessageMetaArrayValues=function(e,t){return v(this,void 0,void 0,(function(){return g(this,(function(n){return k(e instanceof he&&e.messageId>0&&t.every((function(e){return e instanceof J}))).throw(_.invalidParameters),e instanceof $?[2,this._updateFileMessageMetaArray(e.messageId,t,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"remove",!0)]}))}))},h.prototype.report=function(e,r){return v(this,void 0,void 0,(function(){var i,a,s,o;return g(this,(function(u){switch(u.label){case 0:return k(n(xe,e)&&t("string",r)).throw(_.invalidParameters),i=T.of(this._iid),a=i.sdkState,s=i.requestQueue,o=new kt({channelUrl:this.url,channelType:this.channelType,userId:a.userId,category:e,description:r}),[4,s.send(o)];case 1:return u.sent(),[2]}}))}))},h.prototype.reportUser=function(e,r,a){return v(this,void 0,void 0,(function(){var s,o,u,c;return g(this,(function(l){switch(l.label){case 0:return k(e instanceof i&&n(xe,r)&&t("string",a)).throw(_.invalidParameters),s=T.of(this._iid),o=s.sdkState,u=s.requestQueue,c=new Qt({channelUrl:this.url,channelType:this.channelType,userId:o.userId,offendingUserId:e.userId,category:r,description:a}),[4,u.send(c)];case 1:return l.sent(),[2]}}))}))},h.prototype.reportMessage=function(e,r,i){return v(this,void 0,void 0,(function(){var a,s,o,u;return g(this,(function(c){switch(c.label){case 0:return k(e instanceof pe&&n(xe,r)&&t("string",i)).throw(_.invalidParameters),a=T.of(this._iid),s=a.sdkState,o=a.requestQueue,u=new zt({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:e.sender.userId,messageId:e.messageId,category:r,description:i}),[4,o.send(u)];case 1:return c.sent(),[2]}}))}))},h.prototype.updatePoll=function(e,n){return v(this,void 0,void 0,(function(){var r,i,a;return g(this,(function(o){switch(o.label){case 0:return k(t("number",e)&&function(e){return t("string",e.title,!0)&&C(e.data)&&t("boolean",e.allowUserSuggestion,!0)&&t("boolean",e.allowMultipleVotes,!0)&&t("number",e.closeAt,!0)}(n)).throw(_.invalidParameters),r=T.of(this._iid).requestQueue,i=new sn(s({pollId:e},n)),[4,r.send(i)];case 1:return a=o.sent(),[2,a.as(on).poll]}}))}))},h.prototype.deletePoll=function(e){return v(this,void 0,void 0,(function(){var n,r,i;return g(this,(function(a){switch(a.label){case 0:return n=t("number",e),k(n).throw(_.invalidParameters),r=T.of(this._iid).requestQueue,i=new un({pollId:e}),[4,r.send(i)];case 1:return a.sent(),[2]}}))}))},h.prototype.closePoll=function(e){return v(this,void 0,void 0,(function(){var n,r,i,a;return g(this,(function(s){switch(s.label){case 0:return n=t("number",e),k(n).throw(_.invalidParameters),r=T.of(this._iid).requestQueue,i=new cn({pollId:e}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(ln).poll]}}))}))},h.prototype.addPollOption=function(e,n){return v(this,void 0,void 0,(function(){var r,i,a,s;return g(this,(function(o){switch(o.label){case 0:return r=t("number",e)&&t("string",n)&&""!==n.trim(),k(r).throw(_.invalidParameters),i=T.of(this._iid).requestQueue,a=new dn({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:n}),[4,i.send(a)];case 1:return s=o.sent(),[2,s.as(hn).poll]}}))}))},h.prototype.updatePollOption=function(e,n,r){return v(this,void 0,void 0,(function(){var i,a,s,o;return g(this,(function(u){switch(u.label){case 0:return i=t("number",e)&&t("number",n)&&t("string",r)&&""!==r.trim(),k(i).throw(_.invalidParameters),a=T.of(this._iid).requestQueue,s=new pn({pollId:e,pollOptionId:n,optionText:r}),[4,a.send(s)];case 1:return o=u.sent(),[2,o.as(fn).poll]}}))}))},h.prototype.deletePollOption=function(e,n){return v(this,void 0,void 0,(function(){var r,i,a;return g(this,(function(s){switch(s.label){case 0:return r=t("number",e)&&t("number",n),k(r).throw(_.invalidParameters),i=T.of(this._iid).requestQueue,a=new mn({pollId:e,pollOptionId:n}),[4,i.send(a)];case 1:return s.sent(),[2]}}))}))},h.prototype.votePoll=function(e,n){return v(this,void 0,void 0,(function(){var i,a,s,o,u,c,l;return g(this,(function(d){switch(d.label){case 0:return i=t("number",e)&&r("number",n),k(i).throw(_.invalidParameters),a=T.of(this._iid),s=a.requestQueue,o=a.dispatcher,u=new vn({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(yn).event,o.dispatch(new Y({event:l,source:x.EVENT_POLL_VOTED})),[2,l]}}))}))},h.prototype.getPollChangeLogsSinceTimestamp=function(e){return v(this,void 0,void 0,(function(){return g(this,(function(n){switch(n.label){case 0:return k(t("number",e)).throw(_.invalidParameters),[4,ye.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,n.sent()]}}))}))},h.prototype.getPollChangeLogsSinceToken=function(e){return v(this,void 0,void 0,(function(){return g(this,(function(n){switch(n.label){case 0:return k(t("string",e,!0)),[4,ye.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,n.sent()]}}))}))},h.prototype.createPollListQuery=function(e){return void 0===e&&(e=10),new me(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})},h.prototype.createPollVoterListQuery=function(e,t,n){return void 0===n&&(n=20),new ve(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})},h}(B);export{jt as A,rt as B,Wt as C,Ie as D,Gt as E,ge as F,je as G,Be as H,We as I,Ke as J,nn as K,gn as L,et as M,Te as N,Xe as O,yn as P,xe as R,Ae as U,Ue as a,we as b,Me as c,Ee as d,be as e,_n as f,Ve as g,Ge as h,Re as i,Se as j,Le as k,Pe as l,ke as m,Oe as n,qe as o,_e as p,Et as q,ft as r,Ce as s,Ft as t,Lt as u,De as v,qt as w,Ct as x,Dt as y,Ht as z}; +import{a4 as e,a as t,M as n,m as r,U as i,a9 as a,g as s,e as o,u,i as c,ay as l,_ as d,A as h,ab as p,f,h as m,b as v,am as y,c as g,S as _,V as T,W as U,az as I,aA as w,Q as M,aa as E,ac as S,aB as b,aC as P,aw as A,au as C,a8 as D,p as L,a1 as R,a5 as q,K as O,a2 as F,ad as N,t as k,ae as Q,aj as z,ai as x,z as G,aD as V,ar as j,a0 as B,r as W,s as K,af as H,aE as Y}from"./__bundle-087816c3.js";import{d as J,A as X,U as Z,F as $,R as ee,T as te,e as ne,f as re,b as ie,c as ae,g as se,h as oe,i as ue,v as ce,j as le,k as de,B as he,S as pe}from"./__bundle-80fd264e.js";import{i as fe,P as me,a as ve,b as ye}from"./__bundle-8f39cad4.js";var ge,_e=100,Te="GroupChannel",Ue="url",Ie=100,we="Message",Me="messageId",Ee="Poll",Se="pollId",be={data:void 0,customType:void 0,mentionType:e.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,mentionedMessageTemplate:void 0,metaArrays:void 0,parentMessageId:void 0,isReplyToChannel:!1,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0,isPinnedMessage:!1},Pe=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(J,s.metaArrays,!0)&&t("number",s.parentMessageId,!0)&&t("boolean",s.isReplyToChannel)&&n(a,s.pushNotificationDeliveryOption,!0)&&t(X,s.appleCriticalAlertOptions,!0)&&t("boolean",s.isPinnedMessage,!0)},Ae=function(e){return{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}},Ce=s(s({},be),{message:"",translationTargetLanguages:void 0,pollId:void 0}),De=function(e){return Pe(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"}(ge||(ge={}));var Le,Re=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},qe=function(e){return e===ge.BLOB||e===ge.FILE},Oe=function(e){return{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}},Fe=s(s({},be),{file:void 0,fileKey:void 0,fileUrl:void 0,fileName:void 0,fileType:void 0,fileSize:void 0,mimeType:void 0,thumbnailSizes:void 0,requireAuth:!1}),Ne=function(e){return Pe(e)&&(c(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})))},ke=function(e){return o({fileInfoList:e.fileInfoList,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption})},Qe=s(s({},be),{fileInfoList:[]}),ze=function(e){return(c(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"}(Le||(Le={}));var xe,Ge=function(){function e(e){var t,r,i,a;this.restrictionType=null,n(Le,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 o(u({restriction_type:e.restrictionType,description:e.description,end_at:e.endAt,remaining_duration:e.remainingDuration}))},e}(),Ve=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.restrictionInfo=new Ge(n),r}return d(t,e),t.payloadify=function(t){return o(u(s(s({},e.payloadify.call(this,t)),Ge.payloadify(t.restrictionInfo))))},t}(i),je={data:void 0,customType:void 0,mentionType:e.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,mentionedMessageTemplate:void 0,metaArrays:void 0,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0},Be=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(J,s.metaArrays,!0)&&n(a,s.pushNotificationDeliveryOption,!0)&&t(X,s.appleCriticalAlertOptions,!0)},We=s(s({},je),{message:void 0,translationTargetLanguages:void 0,pollId:void 0}),Ke=function(e){return Be(e)&&t("string",e.message,!0)&&r("string",e.translationTargetLanguages,!0)&&t("number",e.pollId,!0)},He=s({},je),Ye=function(e){function t(t){var n=t.channelUrl,r=t.channelType,i=t.token,a=t.limit,s=e.call(this)||this;return s.method=h.GET,s.path="".concat(p(r),"/").concat(encodeURIComponent(n),"/operators"),s.params={token:i,limit:a},s}return d(t,e),t}(f),Je=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.operators=n.operators.map((function(e){return new i(t,e)})),r.token=n.next,r}return d(t,e),t}(m),Xe=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return d(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return v(this,void 0,void 0,(function(){var e,t,n,r,i,a,o;return g(this,(function(u){switch(u.label){case 0:return this._validate()?this._isLoading?[3,3]:(e=[],this._hasNext?(this._isLoading=!0,t=T.of(this._iid).requestQueue,n=new Ye(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(Je),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 _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},t}(y),Ze=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.limit,s=t.token;return(n=e.call(this)||this).method=h.GET,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/mute"),n.params={limit:a,token:s},n}return d(t,e),t}(f),$e=function(e){function t(t,n){var r=e.call(this,t,n)||this;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 Ve(t,e)}))),r}return d(t,e),t}(m),et=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return d(t,e),t.prototype.next=function(){return v(this,void 0,void 0,(function(){var e,t,n,r,i,a;return g(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=T.of(this._iid).requestQueue,t=new Ze(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as($e),i=r.mutedUsers,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},t}(y),tt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.limit,s=t.token;return(n=e.call(this)||this).method=h.GET,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/ban"),n.params=o({limit:a,token:s}),n}return d(t,e),t}(f),nt=function(e){function t(t,n){var r=e.call(this,t,n)||this;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 Ve(t,e.user)}))),r}return d(t,e),t}(m),rt=function(e){function t(t,n,r,i){return e.call(this,t,n,r,i)||this}return d(t,e),t.prototype._validate=function(){return e.prototype._validate.call(this)},t.prototype.next=function(){return v(this,void 0,void 0,(function(){var e,t,n,r,i,a;return g(this,(function(o){switch(o.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=T.of(this._iid).requestQueue,t=new tt(s(s({},this),{token:this._token})),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=o.sent(),r=n.as(nt),i=r.bannedUsers,a=r.token,this._token=a,this._hasNext=!!a,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw _.queryInProgress;case 4:return[3,6];case 5:throw _.invalidParameters;case 6:return[2]}}))}))},t}(y);!function(e){e.SPAM="spam",e.HARASSING="harassing",e.SUSPICIOUS="suspicious",e.INAPPROPRIATE="inappropriate"}(xe||(xe={}));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=h.POST,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var at=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.operatorUserIds;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/operators"),n.params={operator_ids:a},n}return d(t,e),t}(f);!function(e){function t(t,n){return e.call(this,t,n)||this}d(t,e)}(m);var st=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=h.GET,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/mute/").concat(a),n}return d(t,e),t}(f),ot=function(e){function t(t,n){var r=e.call(this,t,n)||this;r.isMuted=!1,r.startAt=0,r.endAt=0;var i=n.is_muted,a=n.start_at,s=n.end_at,o=n.remaining_duration,u=n.description;return r.isMuted=i,r.startAt=a,r.endAt=s,r.remainingDuration=o,r.description=u,r}return d(t,e),t}(m),ut=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.keys;return(n=e.call(this)||this).method=h.GET,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={keys:a,include_ts:!0},n}return d(t,e),t}(f),ct=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.metadata,a=n.ts;return r.metadata=i,r.ts=a,r}return d(t,e),t}(m),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=h.POST,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0},n}return d(t,e),t}(f),dt=function(e){function t(t,n){var r,i,a=this;return(a=e.call(this,t,n)||this).metaData=null!==(r=n.metadata)&&void 0!==r?r:{},a.ts=null!==(i=n.ts)&&void 0!==i?i:null,a}return d(t,e),t}(m),ht=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metadata,s=t.upsert;return(n=e.call(this)||this).method=h.PUT,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={metadata:a,include_ts:!0,upsert:null!=s&&s},n}return d(t,e),t}(f),pt=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.metadata,a=n.ts;return r.metadata=i,r.ts=a,r}return d(t,e),t}(m),ft=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return r.data&&(i.created=r.data.created,i.updated=r.data.updated,i.deleted=r.data.deleted),i}return d(t,e),t}(U),mt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.key;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metadata/").concat(a),n.params={include_ts:!0},n}return d(t,e),t}(f),vt=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.ts;return r.ts=i,r}return d(t,e),t}(m),yt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metadata"),n.params={include_ts:!0},n}return d(t,e),t}(f),gt=function(e){function t(t,n){var r=e.call(this,t,n)||this,i=n.ts;return r.ts=i,r}return d(t,e),t}(m),_t=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.keys;return(n=e.call(this)||this).method=h.GET,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={keys:a},n}return d(t,e),t}(f),Tt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return d(t,e),t}(m),Ut=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metaCounter;return(n=e.call(this)||this).method=h.POST,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a},n}return d(t,e),t}(f),It=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return d(t,e),t}(m),wt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.metaCounter,s=t.upsert,o=void 0!==s&&s,u=t.mode,c=void 0===u?"set":u;return(n=e.call(this)||this).method=h.PUT,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={metacounter:a,upsert:o,mode:c},n}return d(t,e),t}(f),Mt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.metaCounter=n,r}return d(t,e),t}(m),Et=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return r.data&&(i.created=r.data.created,i.updated=r.data.updated,i.deleted=r.data.deleted),i}return d(t,e),t}(U),St=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.key;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metacounter/").concat(a),n.params={},n}return d(t,e),t}(f);!function(e){function t(t,n){return e.call(this,t,n)||this}d(t,e)}(m);var bt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/metacounter"),n.params={},n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var Pt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId,s=t.seconds,o=t.description;return(n=e.call(this)||this).method=h.POST,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/mute"),n.params={user_id:a,seconds:s,description:o},n}return d(t,e),t}(f);!function(e){function t(t,n){return e.call(this,t,n)||this}d(t,e)}(m);var At=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ve(t,r.data),i}return d(t,e),t}(U),Ct=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/mute/").concat(encodeURIComponent(a)),n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var Dt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ve(t,r.data),i}return d(t,e),t}(U),Lt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId,s=t.seconds,u=t.description;return(n=e.call(this)||this).method=h.POST,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/ban"),n.params=o({user_id:a,seconds:s,description:u}),n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var Rt=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ve(t,r.data),r.data.member_count&&(i.memberCount=r.data.member_count),r.data.joined_member_count&&(i.joinedMemberCount=r.data.joined_member_count),i}return d(t,e),t}(U),qt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.userId;return(n=e.call(this)||this).method=h.DELETE,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/ban/").concat(encodeURIComponent(a)),n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var Ot=function(e){function t(t,n,r){var i=e.call(this,t,"SYEV",r)||this;return i.user=new Ve(t,r.data),i}return d(t,e),t}(U),Ft=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.freezing;return(n=e.call(this)||this).method=h.PUT,n.path="".concat(p(i),"/").concat(encodeURIComponent(r),"/freeze"),n.params={freeze:a},n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var 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 d(t,e),t}(U),kt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.category,s=t.userId,o=t.description;return(n=e.call(this)||this).method=h.POST,n.path="".concat(I(i),"/").concat(encodeURIComponent(r)),n.params={report_category:a,reporting_user_id:s,report_description:o},n}return d(t,e),t}(f),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.description;return(n=e.call(this)||this).method=h.POST,n.path="".concat(w,"/users/").concat(o),n.params={channel_url:r,channel_type:i===M.OPEN?"open_channels":"group_channels",report_category:a,reporting_user_id:s,report_description:u},n}return d(t,e),t}(f),zt=function(e){function t(t){var n=this,r=t.channelUrl,i=t.channelType,a=t.category,s=t.userId,o=t.offendingUserId,u=t.messageId,c=t.description;return(n=e.call(this)||this).method=h.POST,n.path="".concat(I(i),"/").concat(encodeURIComponent(r),"/messages/").concat(u),n.params={report_category:a,reporting_user_id:s,report_description:c,offending_user_id:o},n}return d(t,e),t}(f),xt=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(u({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?n.parentMessageId:null,req_id:n.reqId,poll_id:n.pollId,pin_message:n.isPinnedMessage}))})||this}return d(n,t),n}(E),Gt=function(e){function t(t,n,r){var i,a,s,o,u=this;(u=e.call(this,t,"MESG",r)||this).message=new Z(t,r);var c=T.of(t).sdkState;return u.isMentioned=S(u.message.mentionType,null!==(s=null!==(i=u.message.mentionedUserIds)&&void 0!==i?i:null===(a=u.message.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})))&&void 0!==s?s:[],c.userId),u.forceUpdateLastMessage=null!==(o=r.force_update_last_message)&&void 0!==o&&o,u}return d(t,e),t}(U),Vt=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:"MEDI",ackRequired:!0,payload:o(u({channel_url:n.channelUrl,msg_id:n.messageId,message:n.message,data:n.data,custom_type:n.customType,metaarray:n.metaArrayParams,mention_type:n.mentionType,mentioned_user_ids:r,mentioned_message_template:n.mentionedMessageTemplate,apple_critical_alert_options:n.appleCriticalAlertOptions?X.payloadify(n.appleCriticalAlertOptions):null,poll_id:n.pollId}))})||this}return d(n,t),n}(E),jt=function(e){function t(t,n,r){var i,a,s,o,c,l=this;(l=e.call(this,t,"MEDI",r)||this).message=new Z(t,r);var d=T.of(t).sdkState;return l.mentionCountChange=b({mentionType:null===(i=r.old_values)||void 0===i?void 0:i.mention_type,mentionedUserIds:null!==(s=null===(a=r.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==s?s:[]},u({mentionType:l.message.mentionType,mentionedUserIds:null!==(o=l.message.mentionedUserIds)&&void 0!==o?o:null===(c=l.message.mentionedUsers)||void 0===c?void 0:c.map((function(e){return e.userId}))}),d.userId),l}return d(t,e),t}(U),Bt=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(u({channel_url:n.channelUrl,msg_id:n.messageId,data:n.data,custom_type:n.customType,metaarray:n.metaArrayParams,mention_type:n.mentionType,mentioned_user_ids:r,apple_critical_alert_options:n.appleCriticalAlertOptions}))})||this}return d(n,t),n}(E),Wt=function(e){function t(t,n,r){var i,a,s,o,c,l=this;(l=e.call(this,t,"FEDI",r)||this).message=new $(t,r);var d=T.of(t).sdkState;return l.mentionCountChange=b({mentionType:null===(i=r.old_values)||void 0===i?void 0:i.mention_type,mentionedUserIds:null!==(s=null===(a=r.old_values)||void 0===a?void 0:a.mentioned_user_ids)&&void 0!==s?s:[]},u({mentionType:l.message.mentionType,mentionedUserIds:null!==(o=l.message.mentionedUserIds)&&void 0!==o?o:null===(c=l.message.mentionedUsers)||void 0===c?void 0:c.map((function(e){return e.userId}))}),d.userId),l}return d(t,e),t}(U),Kt=function(e){function t(t){var n=e.call(this)||this;return n.method=h.DELETE,n.path="".concat(p(t.channelType),"/").concat(t.channelUrl,"/messages/").concat(t.messageId),n}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var Ht=function(e){function t(t,n,r){var i=e.call(this,t,"DELM",r)||this;return i.channelUrl=r.channel_url,i.channelType=r.channel_type,i.messageId=Number(r.msg_id),i}return d(t,e),t}(U),Yt=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.reactionKey,s=e.call(this)||this;return s.method=h.POST,s.path="".concat(p(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/reactions"),s.params={reaction:a},s}return d(t,e),t}(f),Jt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new ee(n),r}return d(t,e),t}(m),Xt=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.reactionKey,s=e.call(this)||this;return s.method=h.DELETE,s.path="".concat(p(n),"/").concat(encodeURIComponent(r),"/messages/").concat(i,"/reactions"),s.params={reaction:a},s}return d(t,e),t}(f),Zt=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.reactionEvent=new ee(s({},n)),r}return d(t,e),t}(m),$t=function(e){function t(t){var n=t.channelType,r=t.channelUrl,i=t.messageId,a=t.translationTargetLanguages,s=e.call(this)||this;return s.method=h.POST,s.path="".concat(p(n),"/").concat(encodeURIComponent(r),"/messages/").concat(encodeURIComponent(i),"/translation"),s.params={target_langs:a},s}return d(t,e),t}(f),en=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new Z(t,n),r}return d(t,e),t}(m),tn=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,c=n.channelUrl;return i.method=h.POST,i.path="".concat(p(s),"/").concat(encodeURIComponent(c),"/scheduled_messages"),i.params=o(u({req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:P.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 J.payloadify(e)})),apple_critical_alert_options:n.appleCriticalAlertOptions?X.payloadify(n.appleCriticalAlertOptions):null,target_langs:n.translationTargetLanguages,push_option:n.pushNotificationDeliveryOption})),i}return d(n,t),n}(f),nn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new Z(t,n),r}return d(t,e),t}(m),rn=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=h.POST,i.path="".concat(p(s),"/").concat(encodeURIComponent(o),"/scheduled_messages"),i.params=u({req_id:n.reqId,scheduled_at:n.scheduledAt,message_type:P.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 te.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 J.payloadify(e)})),apple_critical_alert_options:n.appleCriticalAlertOptions?X.payloadify(n.appleCriticalAlertOptions):null,push_option:n.pushNotificationDeliveryOption}),i}return d(n,t),n}(f),an=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.message=new $(t,n),r}return d(t,e),t}(m),sn=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=h.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 d(t,e),t}(f),on=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new D(t,n),r}return d(t,e),t}(m),un=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=h.DELETE,r.path="".concat(C,"/").concat(encodeURIComponent(n)),r}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var cn=function(e){function t(t){var n=t.pollId,r=e.call(this)||this;return r.method=h.PUT,r.path="".concat(C,"/").concat(encodeURIComponent(n),"/close"),r}return d(t,e),t}(f),ln=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new D(t,n),r}return d(t,e),t}(m),dn=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=h.POST,s.path="".concat(C,"/").concat(encodeURIComponent(i),"/options"),s.params={channel_url:n,channel_type:r,text:a},s}return d(t,e),t}(f),hn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new D(t,n),r}return d(t,e),t}(m),pn=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,i=t.optionText,a=e.call(this)||this;return a.method=h.PUT,a.path="".concat(C,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),a.params={text:i},a}return d(t,e),t}(f),fn=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.poll=new D(t,n),r}return d(t,e),t}(m),mn=function(e){function t(t){var n=t.pollId,r=t.pollOptionId,i=e.call(this)||this;return i.method=h.DELETE,i.path="".concat(C,"/").concat(encodeURIComponent(n),"/options/").concat(encodeURIComponent(r)),i}return d(t,e),t}(f);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}d(t,e)}(m);var vn=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===M.OPEN?"open_channels":"group_channels",channel_url:i,poll_id:a,option_ids:s})})||this}return d(t,e),t}(E),yn=function(e){function t(t,n,r){var i=e.call(this,t,"VOTE",r)||this;return i.event=new fe(r),i.channelUrl=r.channel_url,i.channelType=r.channel_type,i}return d(t,e),t}(U),gn=2,_n=function(e){function h(n,r){var a,s,o,u,c=this;return(c=e.call(this,n)||this).channelType=M.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 d(h,e),h.payloadify=function(t){return o(u(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:t.creator?i.payloadify(t.creator):null,created_at:t.createdAt/1e3})))},h.prototype.isGroupChannel=function(){return this.channelType===M.GROUP},h.prototype.isOpenChannel=function(){return this.channelType===M.OPEN},Object.defineProperty(h.prototype,"cachedMetaData",{get:function(){var e={};return this._cachedMetaData?(this._cachedMetaData.forEach((function(t,n){t.isRemoved||(e[n]=t.value)})),e):e},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"messageCollectionLastAccessedAt",{get:function(){return this._messageCollectionLastAccessedAt},enumerable:!1,configurable:!0}),h.prototype._updateMessageCollectionLastAccessedAt=function(){this._messageCollectionLastAccessedAt=Date.now()},h.prototype._update=function(e){var t=o(e);Object.assign(this,t)},h.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})}))},h.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(_.invalidParameters),n=T.of(this._iid).requestQueue,i=new $t({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,translationTargetLanguages:t}),[4,n.send(i)];case 1:return a=s.sent(),[2,a.as(en).message]}}))}))},h.prototype._createScheduledUserMessage=function(e,t){var n=this,r=T.of(this._iid).requestQueue,i=Date.now(),a=this._generateRequestId();Q(2).then((function(){var r=n._createPendingScheduledUserMessage(e,a,i);G((function(){return v(n,void 0,void 0,(function(){return g(this,(function(e){return[2,t._trigger(r)]}))}))}))}));var o=new tn(s({reqId:a,channelType:this.channelType,channelUrl:this.url},e));r.send(o).then((function(e){var r=e.as(nn).message;G((function(){return v(n,void 0,void 0,(function(){return g(this,(function(e){return[2,t._trigger(r)]}))}))}))})).catch((function(r){if(V(r))throw r;Q(2).then((function(){var s=n._createPendingScheduledUserMessage(e,a,i);n._markMessageAsFailed(s,r),G((function(){return v(n,void 0,void 0,(function(){return g(this,(function(e){return[2,t._trigger(s)]}))}))}))}))}))},h.prototype.sendFileMessage=function(e){var t=s(s({},Fe),e);return k(Ne(t)).throw(_.invalidParameters),this._sendFileMessage(t)},h.prototype.sendMultipleFilesMessage=function(e){var t,n=s(s({},Qe),e),r=T.of(this._iid);k(function(e,t){return void 0===t&&(t=l),Pe(e)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=t&&e.fileInfoList.every((function(e){return ze(e)}))}(n,null===(t=r.appInfo)||void 0===t?void 0:t.multipleFilesMessageFileCountLimit)).throw(_.invalidParameters);var i=!!e.fileInfoList.find((function(e){var t=r.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return k(!i).throw(_.fileSizeLimitExceededError),this._sendMultipleFilesMessage(n)},h.prototype._sendFileMessage=function(e,t,n){var r=this;void 0===n&&(n=!1);var i=T.of(this._iid),a=i.dispatcher;i.sessionManager;var s=ae.of(this._iid).fileMessageQueue,o=null!=t?t:this._generateRequestId(),u=Date.now(),c=new oe;return o||(o=this._generateRequestId()),Q(2).then((function(){var t=r._createPendingFileMessage(e,o,u);a.dispatch(new z({messages:[t],source:n?x.LOCAL_MESSAGE_RESEND_STARTED:x.EVENT_MESSAGE_SENT_PENDING})),G((function(){return v(r,void 0,void 0,(function(){return g(this,(function(e){return[2,c._trigger(t)]}))}))})),s.request(r,o,e).then((function(e){a.dispatch(new z({messages:[e],source:x.EVENT_MESSAGE_SENT_SUCCESS})),G((function(){return v(r,void 0,void 0,(function(){return g(this,(function(t){return[2,c._trigger(e)]}))}))}))})).catch((function(t){if(V(t))throw t;Q(2).then((function(){var n=r._createPendingFileMessage(e,o,u),i=T.of(r._iid).cacheContext.localCacheEnabled&&j(t.code);r._markMessageAsFailed(n,t,i),a.dispatch(new z({messages:[n],source:n.sendingStatus===q.PENDING?x.REQUEST_RESEND_MESSAGE:t.code===N.FILE_UPLOAD_CANCEL_FAILED?x.LOCAL_MESSAGE_CANCELED:x.EVENT_MESSAGE_SENT_FAILED})),G((function(){return v(r,void 0,void 0,(function(){return g(this,(function(e){return[2,c._triggerFailed(t,n)]}))}))}))}))}))})),c},h.prototype._autoResendFileMessage=function(e){k(e instanceof $&&!!e.messageParams).throw(_.invalidParameters);var t=T.of(this._iid).logger;return t.debug("autoResendFileMessage pending",e),this._sendFileMessage(e.messageParams,e.reqId).onFailed((function(e){t.debug("autoResendFileMessage failed",e)})).onSucceeded((function(e){t.debug("autoResendFileMessage success",e)}))},h.prototype._sendMultipleFilesMessage=function(e,t){var n=this,r=T.of(this._iid),i=r.dispatcher;r.sessionManager;var a=ae.of(this._iid).fileMessageQueue,s=null!=t?t:this._generateRequestId(),o=Date.now(),u=new se;return s||(s=this._generateRequestId()),Q(2).then((function(){var t=n._createPendingMultipleFilesMessage(e,s,o);i.dispatch(new z({messages:[t],source:x.EVENT_MESSAGE_SENT_PENDING})),G((function(){return v(n,void 0,void 0,(function(){return g(this,(function(e){return[2,u._trigger(t)]}))}))})),a.request(n,s,e,u).then((function(e){i.dispatch(new z({messages:[e],source:x.EVENT_MESSAGE_SENT_SUCCESS})),G((function(){return v(n,void 0,void 0,(function(){return g(this,(function(t){return[2,u._trigger(e)]}))}))}))})).catch((function(t){if(V(t))throw t;Q(2).then((function(){var r=n._createPendingMultipleFilesMessage(e,s,o);n._markMessageAsFailed(r,t),i.dispatch(new z({messages:[r],source:x.EVENT_MESSAGE_SENT_FAILED})),G((function(){return v(n,void 0,void 0,(function(){return g(this,(function(e){return[2,u._triggerFailed(t,r)]}))}))}))}))}))})),u},h.prototype._createScheduledFileMessage=function(e,t,n,r){var i=this,a=T.of(this._iid).requestQueue,o=new rn(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(an).message;G((function(){return v(i,void 0,void 0,(function(){return g(this,(function(e){return[2,t._trigger(n)]}))}))}))})).catch((function(a){if(V(a))throw a;Q(2).then((function(){var s=i._createPendingScheduledFileMessage(e,n,r);i._markMessageAsFailed(s,a),G((function(){return v(i,void 0,void 0,(function(){return g(this,(function(e){return[2,t._triggerFailed(a,s)]}))}))}))}))}))},h.prototype.sendFileMessages=function(e){var t,n;k(e.every((function(e){return Ne(s(s({},Fe),e))}))).throw(_.invalidParameters);var r=new oe;try{for(var i=O(e),a=i.next();!a.done;a=i.next()){var o=a.value;this.sendFileMessage(o).onPending((function(e){return r._trigger(e)})).onFailed((function(e,t){return r._triggerFailed(e,t)})).onSucceeded((function(e){return r._trigger(e)}))}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r},h.prototype.resendFileMessage=function(e,t){var n;return v(this,void 0,void 0,(function(){var r,i,a;return g(this,(function(s){return r=Boolean(e.url)||c(t)||c(null===(n=e.messageParams)||void 0===n?void 0:n.file),k(e instanceof $&&r&&!e.scheduledInfo).throw(_.invalidParameters),i=new H,a=function(e,t){var n;return e.messageParams?(!e.url&&c(t)&&(e.messageParams.file=t),e.messageParams):o(u({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,file:t,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:null===(n=e.thumbnails)||void 0===n?void 0:n.map((function(e){return{maxWidth:e.width,maxHeight:e.height}}))}))}(e,t),this._sendFileMessage(a,e.reqId,!0).onFailed((function(e){return i.reject(e)})).onSucceeded((function(e){return i.resolve(e)})),[2,i.promise]}))}))},h.prototype.updateFileMessage=function(e,n){return v(this,void 0,void 0,(function(){var r,i,a,o;return g(this,(function(u){switch(u.label){case 0:return r=s(s({},He),n),k(t("number",e)&&function(e){return Be(e)}(r)).throw(_.invalidParameters),i=T.of(this._iid).requestQueue,a=new Bt(s({channelType:this.channelType,channelUrl:this.url,messageId:e},r)),[4,i.send(a)];case 1:return o=u.sent(),[2,o.as(Wt).message]}}))}))},h.prototype.cancelUploadingFileMessage=function(e){return v(this,void 0,void 0,(function(){return g(this,(function(n){return k(t("string",e)).throw(_.invalidParameters),ae.of(this._iid).fileMessageQueue.cancel(this,e),[2,!0]}))}))},h.prototype.copyFileMessage=function(e,t){var n,r,i;return v(this,void 0,void 0,(function(){var o,c;return g(this,(function(l){return k(e instanceof h&&t instanceof $&&t.sendingStatus===q.SUCCEEDED&&this.url===t.channelUrl&&!t.scheduledInfo).throw(_.invalidParameters),o=new H,c=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(c).onSucceeded((function(e){return o.resolve(e)})).onFailed((function(e){return o.reject(e)})),[2,o.promise]}))}))},h.prototype.deleteMessage=function(e){return v(this,void 0,void 0,(function(){var t,n;return g(this,(function(r){switch(r.label){case 0:return k(e instanceof he).throw(_.invalidParameters),e.messageId>0?(t=T.of(this._iid).requestQueue,n=new Kt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId}),[4,t.send(n)]):[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}}))}))},h.prototype.addReaction=function(e,n){return v(this,void 0,void 0,(function(){var r,i,a;return g(this,(function(s){switch(s.label){case 0:return k(e instanceof he&&e.messageId>0&&t("string",n)).throw(_.invalidParameters),r=T.of(this._iid).requestQueue,i=new Yt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(Jt).reactionEvent]}}))}))},h.prototype.deleteReaction=function(e,n){return v(this,void 0,void 0,(function(){var r,i,a;return g(this,(function(s){switch(s.label){case 0:return k(e instanceof he&&e.messageId>0&&t("string",n)).throw(_.invalidParameters),r=T.of(this._iid).requestQueue,i=new Xt({channelType:this.channelType,channelUrl:this.url,messageId:e.messageId,reactionKey:n}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(Zt).reactionEvent]}}))}))},h.prototype._updateUserMessageMetaArray=function(e,t,n,r){return v(this,void 0,void 0,(function(){var i,a,s,o,u,c;return g(this,(function(l){switch(l.label){case 0:return i=T.of(this._iid),a=i.dispatcher,s=i.requestQueue,o=new Vt({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(jt).message,a.dispatch(new z({messages:[c],source:x.EVENT_MESSAGE_UPDATED})),[2,c]}}))}))},h.prototype._updateFileMessageMetaArray=function(e,t,n,r){return v(this,void 0,void 0,(function(){var i,a,s,o,u,c;return g(this,(function(l){switch(l.label){case 0:return i=T.of(this._iid),a=i.dispatcher,s=i.requestQueue,o=new Bt({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(Wt).message,a.dispatch(new z({messages:[c],source:x.EVENT_MESSAGE_UPDATED})),[2,c]}}))}))},h.prototype.createMessageMetaArrayKeys=function(e,t){return v(this,void 0,void 0,(function(){var n;return g(this,(function(i){return k(e instanceof he&&e.messageId>0&&r("string",t)).throw(_.invalidParameters),n=t.map((function(e){return new J({key:e})})),e instanceof $?[2,this._updateFileMessageMetaArray(e.messageId,n,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"add",!0)]}))}))},h.prototype.deleteMessageMetaArrayKeys=function(e,t){return v(this,void 0,void 0,(function(){var n;return g(this,(function(i){return k(e instanceof he&&e.messageId>0&&r("string",t)).throw(_.invalidParameters),n=t.map((function(e){return new J({key:e})})),e instanceof $?[2,this._updateFileMessageMetaArray(e.messageId,n,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,n,"remove",!0)]}))}))},h.prototype.addMessageMetaArrayValues=function(e,t){return v(this,void 0,void 0,(function(){return g(this,(function(n){return k(e instanceof he&&e.messageId>0&&t.every((function(e){return e instanceof J}))).throw(_.invalidParameters),e instanceof $?[2,this._updateFileMessageMetaArray(e.messageId,t,"add",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"add",!0)]}))}))},h.prototype.removeMessageMetaArrayValues=function(e,t){return v(this,void 0,void 0,(function(){return g(this,(function(n){return k(e instanceof he&&e.messageId>0&&t.every((function(e){return e instanceof J}))).throw(_.invalidParameters),e instanceof $?[2,this._updateFileMessageMetaArray(e.messageId,t,"remove",!0)]:[2,this._updateUserMessageMetaArray(e.messageId,t,"remove",!0)]}))}))},h.prototype.report=function(e,r){return v(this,void 0,void 0,(function(){var i,a,s,o;return g(this,(function(u){switch(u.label){case 0:return k(n(xe,e)&&t("string",r)).throw(_.invalidParameters),i=T.of(this._iid),a=i.sdkState,s=i.requestQueue,o=new kt({channelUrl:this.url,channelType:this.channelType,userId:a.userId,category:e,description:r}),[4,s.send(o)];case 1:return u.sent(),[2]}}))}))},h.prototype.reportUser=function(e,r,a){return v(this,void 0,void 0,(function(){var s,o,u,c;return g(this,(function(l){switch(l.label){case 0:return k(e instanceof i&&n(xe,r)&&t("string",a)).throw(_.invalidParameters),s=T.of(this._iid),o=s.sdkState,u=s.requestQueue,c=new Qt({channelUrl:this.url,channelType:this.channelType,userId:o.userId,offendingUserId:e.userId,category:r,description:a}),[4,u.send(c)];case 1:return l.sent(),[2]}}))}))},h.prototype.reportMessage=function(e,r,i){return v(this,void 0,void 0,(function(){var a,s,o,u;return g(this,(function(c){switch(c.label){case 0:return k(e instanceof pe&&n(xe,r)&&t("string",i)).throw(_.invalidParameters),a=T.of(this._iid),s=a.sdkState,o=a.requestQueue,u=new zt({channelUrl:this.url,channelType:this.channelType,userId:s.userId,offendingUserId:e.sender.userId,messageId:e.messageId,category:r,description:i}),[4,o.send(u)];case 1:return c.sent(),[2]}}))}))},h.prototype.updatePoll=function(e,n){return v(this,void 0,void 0,(function(){var r,i,a;return g(this,(function(o){switch(o.label){case 0:return k(t("number",e)&&function(e){return t("string",e.title,!0)&&A(e.data)&&t("boolean",e.allowUserSuggestion,!0)&&t("boolean",e.allowMultipleVotes,!0)&&t("number",e.closeAt,!0)}(n)).throw(_.invalidParameters),r=T.of(this._iid).requestQueue,i=new sn(s({pollId:e},n)),[4,r.send(i)];case 1:return a=o.sent(),[2,a.as(on).poll]}}))}))},h.prototype.deletePoll=function(e){return v(this,void 0,void 0,(function(){var n,r,i;return g(this,(function(a){switch(a.label){case 0:return n=t("number",e),k(n).throw(_.invalidParameters),r=T.of(this._iid).requestQueue,i=new un({pollId:e}),[4,r.send(i)];case 1:return a.sent(),[2]}}))}))},h.prototype.closePoll=function(e){return v(this,void 0,void 0,(function(){var n,r,i,a;return g(this,(function(s){switch(s.label){case 0:return n=t("number",e),k(n).throw(_.invalidParameters),r=T.of(this._iid).requestQueue,i=new cn({pollId:e}),[4,r.send(i)];case 1:return a=s.sent(),[2,a.as(ln).poll]}}))}))},h.prototype.addPollOption=function(e,n){return v(this,void 0,void 0,(function(){var r,i,a,s;return g(this,(function(o){switch(o.label){case 0:return r=t("number",e)&&t("string",n)&&""!==n.trim(),k(r).throw(_.invalidParameters),i=T.of(this._iid).requestQueue,a=new dn({channelUrl:this.url,channelType:this.channelType,pollId:e,optionText:n}),[4,i.send(a)];case 1:return s=o.sent(),[2,s.as(hn).poll]}}))}))},h.prototype.updatePollOption=function(e,n,r){return v(this,void 0,void 0,(function(){var i,a,s,o;return g(this,(function(u){switch(u.label){case 0:return i=t("number",e)&&t("number",n)&&t("string",r)&&""!==r.trim(),k(i).throw(_.invalidParameters),a=T.of(this._iid).requestQueue,s=new pn({pollId:e,pollOptionId:n,optionText:r}),[4,a.send(s)];case 1:return o=u.sent(),[2,o.as(fn).poll]}}))}))},h.prototype.deletePollOption=function(e,n){return v(this,void 0,void 0,(function(){var r,i,a;return g(this,(function(s){switch(s.label){case 0:return r=t("number",e)&&t("number",n),k(r).throw(_.invalidParameters),i=T.of(this._iid).requestQueue,a=new mn({pollId:e,pollOptionId:n}),[4,i.send(a)];case 1:return s.sent(),[2]}}))}))},h.prototype.votePoll=function(e,n){return v(this,void 0,void 0,(function(){var i,a,s,o,u,c,l;return g(this,(function(d){switch(d.label){case 0:return i=t("number",e)&&r("number",n),k(i).throw(_.invalidParameters),a=T.of(this._iid),s=a.requestQueue,o=a.dispatcher,u=new vn({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(yn).event,o.dispatch(new Y({event:l,source:x.EVENT_POLL_VOTED})),[2,l]}}))}))},h.prototype.getPollChangeLogsSinceTimestamp=function(e){return v(this,void 0,void 0,(function(){return g(this,(function(n){switch(n.label){case 0:return k(t("number",e)).throw(_.invalidParameters),[4,ye.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,n.sent()]}}))}))},h.prototype.getPollChangeLogsSinceToken=function(e){return v(this,void 0,void 0,(function(){return g(this,(function(n){switch(n.label){case 0:return k(t("string",e,!0)),[4,ye.of(this._iid).getPollChangeLogs(this.url,this.channelType,e)];case 1:return[2,n.sent()]}}))}))},h.prototype.createPollListQuery=function(e){return void 0===e&&(e=10),new me(this._iid,{channelUrl:this.url,channelType:this.channelType,limit:e})},h.prototype.createPollVoterListQuery=function(e,t,n){return void 0===n&&(n=20),new ve(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})},h}(B);export{jt as A,rt as B,Wt as C,Ie as D,Gt as E,ge as F,je as G,Be as H,We as I,Ke as J,nn as K,gn as L,et as M,Te as N,Xe as O,yn as P,xe as R,Ce as U,Ue as a,we as b,Me as c,Ee as d,Se as e,_n as f,Ve as g,Ge as h,Le as i,be as j,Oe as k,Pe as l,ke as m,qe as n,Re as o,_e as p,Et as q,ft as r,Ae as s,Nt as t,Ot as u,De as v,Rt as w,At as x,Dt as y,Ht as z}; diff --git a/lib/__bundle-57274663.js b/lib/__bundle-57274663.js deleted file mode 100644 index 8224639..0000000 --- a/lib/__bundle-57274663.js +++ /dev/null @@ -1 +0,0 @@ -var t="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==t&&t,e={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(e.arrayBuffer)var r=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],o=ArrayBuffer.isView||function(t){return t&&r.indexOf(Object.prototype.toString.call(t))>-1};function n(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||""===t)throw new TypeError('Invalid character in header field name: "'+t+'"');return t.toLowerCase()}function i(t){return"string"!=typeof t&&(t=String(t)),t}function s(t){var r={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return e.iterable&&(r[Symbol.iterator]=function(){return r}),r}function a(t){this.map={},t instanceof a?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function h(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function f(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function u(t){var e=new FileReader,r=f(e);return e.readAsArrayBuffer(t),r}function d(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function c(){return this.bodyUsed=!1,this._initBody=function(t){var r;this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:e.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:e.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:e.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():e.arrayBuffer&&e.blob&&((r=t)&&DataView.prototype.isPrototypeOf(r))?(this._bodyArrayBuffer=d(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):e.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||o(t))?this._bodyArrayBuffer=d(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):e.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},e.blob&&(this.blob=function(){var t=h(this);if(t)return t;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 t=h(this);return t||(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(u)}),this.text=function(){var t,e,r,o=h(this);if(o)return o;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=f(e),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),o=0;o-1?o:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(n),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==e.cache&&"no-cache"!==e.cache)){var i=/([?&])_=[^&]*/;if(i.test(this.url))this.url=this.url.replace(i,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function p(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),o=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(o),decodeURIComponent(n))}})),e}function b(t,e){if(!(this instanceof b))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText=void 0===e.statusText?"":""+e.statusText,this.headers=new a(e.headers),this.url=e.url||"",this._initBody(t)}l.prototype.clone=function(){return new l(this,{body:this._bodyInit})},c.call(l.prototype),c.call(b.prototype),b.prototype.clone=function(){return new b(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new a(this.headers),url:this.url})},b.error=function(){var t=new b(null,{status:0,statusText:""});return t.type="error",t};var m=[301,302,303,307,308];b.redirect=function(t,e){if(-1===m.indexOf(e))throw new RangeError("Invalid status code");return new b(null,{status:e,headers:{location:t}})};var w=t.DOMException;try{new w}catch(t){(w=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack}).prototype=Object.create(Error.prototype),w.prototype.constructor=w}function v(r,o){return new Promise((function(n,s){var h=new l(r,o);if(h.signal&&h.signal.aborted)return s(new w("Aborted","AbortError"));var f=new XMLHttpRequest;function u(){f.abort()}f.onload=function(){var t,e,r={status:f.status,statusText:f.statusText,headers:(t=f.getAllResponseHeaders()||"",e=new a,t.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(t){return 0===t.indexOf("\n")?t.substr(1,t.length):t})).forEach((function(t){var r=t.split(":"),o=r.shift().trim();if(o){var n=r.join(":").trim();e.append(o,n)}})),e)};r.url="responseURL"in f?f.responseURL:r.headers.get("X-Request-URL");var o="response"in f?f.response:f.responseText;setTimeout((function(){n(new b(o,r))}),0)},f.onerror=function(){setTimeout((function(){s(new TypeError("Network request failed"))}),0)},f.ontimeout=function(){setTimeout((function(){s(new TypeError("Network request failed"))}),0)},f.onabort=function(){setTimeout((function(){s(new w("Aborted","AbortError"))}),0)},f.open(h.method,function(e){try{return""===e&&t.location.href?t.location.href:e}catch(t){return e}}(h.url),!0),"include"===h.credentials?f.withCredentials=!0:"omit"===h.credentials&&(f.withCredentials=!1),"responseType"in f&&(e.blob?f.responseType="blob":e.arrayBuffer&&h.headers.get("Content-Type")&&-1!==h.headers.get("Content-Type").indexOf("application/octet-stream")&&(f.responseType="arraybuffer")),!o||"object"!=typeof o.headers||o.headers instanceof a?h.headers.forEach((function(t,e){f.setRequestHeader(e,t)})):Object.getOwnPropertyNames(o.headers).forEach((function(t){f.setRequestHeader(t,i(o.headers[t]))})),h.signal&&(h.signal.addEventListener("abort",u),f.onreadystatechange=function(){4===f.readyState&&h.signal.removeEventListener("abort",u)}),f.send(void 0===h._bodyInit?null:h._bodyInit)}))}v.polyfill=!0,t.fetch||(t.fetch=v,t.Headers=a,t.Request=l,t.Response=b); diff --git a/lib/__bundle-75942676.js b/lib/__bundle-75942676.js deleted file mode 100644 index 2e20941..0000000 --- a/lib/__bundle-75942676.js +++ /dev/null @@ -1 +0,0 @@ -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="object"==typeof e&&null!==e&&e.hasOwnProperty("name")&&"string"==typeof e.name&&e.hasOwnProperty("uri")&&"string"==typeof e.uri&&e.hasOwnProperty("type")&&"string"==typeof e.type;if(!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}(),I={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),s?(this._clearOrder=o,this._customClearOrderComparator=s):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}(),V=function(){function e(){}return Object.defineProperty(e.prototype,"hasSession",{get:function(){return!!this.sessionKey},enumerable:!1,configurable:!0}),e.prototype.clear=function(){this.authToken=void 0,this.sessionKey=void 0},e}(),Z=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=Z()}return e.prototype._register=function(e,t,n){var r;return e in this._container||(this._container[e]=new Map),null===(r=this._container[e])||void 0===r||r.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(){var e;for(var t in this._container)null===(e=this._container[t])||void 0===e||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},J=function(e){if(null!=e){if("object"==typeof e){if(Array.isArray(e)){var t=c([],a(e),!1);for(var n in t)t[n]=J(t[n]);return t}for(var r in e)null===e[r]&&delete e[r];return e}return e}};!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 $,ee="v3",te="/".concat(ee,"/users"),ne="/".concat(ee,"/storage/file"),re="/".concat(ee,"/group_channels"),ie="/".concat(ee,"/sdk/group_channels"),oe="/".concat(ee,"/open_channels"),se="/".concat(ee,"/sdk/open_channels"),ae="/".concat(ee,"/search"),ce="/".concat(ee,"/report"),ue="/".concat(ee,"/emojis"),le="/".concat(ee,"/emoji_categories"),he="/".concat(ee,"/polls"),de="/".concat(ee,"/scheduled_messages"),_e="/".concat(ee,"/sdk/ui_kit/configuration"),fe="/".concat(ee,"/sdk/statistics"),pe=function(e){switch(e){case x.GROUP:return re;case x.OPEN:return oe;default:return null}},ge=function(e){switch(e){case x.GROUP:return"".concat(ce,"/group_channels");case x.OPEN:return"".concat(ce,"/open_channels");default:return null}},ve=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},Ee=function(e,t,n){var r,i,o,s,a=ve(null!==(r=e.mentionType)&&void 0!==r?r:null,null!==(i=e.mentionedUserIds)&&void 0!==i?i:[],n),c=ve(null!==(o=t.mentionType)&&void 0!==o?o:null,null!==(s=t.mentionedUserIds)&&void 0!==s?s:[],n);return!a&&c?1:a&&!c?-1:0},be=function(e,t,n){var r,i=t||new FormData;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){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=be(s,i,a)}return i};!function(e){e.GET="GET",e.POST="POST",e.PUT="PUT",e.DELETE="DELETE"}($||($={}));var me,ye=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.params={},t.requireAuth=!0,t.headers={},t.requestId=Z(),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])}))?be(e):JSON.stringify(e)},enumerable:!1,configurable:!0}),n}(Y),we=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),Se=function(e){function n(t){var n=e.call(this)||this;return n.requestId=t,n}return t(n,e),n}(Y),ke=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),Te=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"}(me||(me={}));var Ce=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}(),Oe=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},Ae=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 Se&&c.cancel(e.requestId)})),this._logger=o,this._shouldImportFetchCompat=a}return Object.defineProperty(e.prototype,"_userAgentWithExtension",{get:function(){var e=this._sdkState.extensions,t=Oe()?"reactnative":"JS",n="//";if(e){var r=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",i=e.sb_uikit?"u".concat(e.sb_uikit):"",o=e["device-os-platform"]?"o".concat(e["device-os-platform"]):"";n="".concat(r,"/").concat(i,"/").concat(o)}return"".concat(t,"/c").concat(h.SDK_VERSION,"/").concat(n)},enumerable:!1,configurable:!0}),e.prototype._createHeader=function(e,t){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 Te(new Ce({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}})))},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=![$.GET,$.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:void 0),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=null),"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),[2,new we(this._iid,_)];throw _?(((f=new E(_)).isSessionKeyExpiredError||f.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new ke({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}(),Ne=function(e){function n(t,n,r,i){void 0===i&&(i="");var o,s=this;return(s=e.call(this)||this)._iid=t,s.code=n,s.payload=r,s.requestId=null!==(o=r.req_id)&&void 0!==o?o:i,s}return t(n,e),n.createFromRawMessage=function(e,t){var r=t.substring(0,4),i={};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),Re=function(){};function Ie(e){let t=e.length;for(;--t>=0;)e[t]=0}const De=256,Le=286,xe=30,Me=15,Pe=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]),Ue=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]),ze=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Fe=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),qe=new Array(576);Ie(qe);const Ge=new Array(60);Ie(Ge);const je=new Array(512);Ie(je);const Ke=new Array(256);Ie(Ke);const Be=new Array(29);Ie(Be);const Ve=new Array(xe);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 He,We,Qe;function Ye(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}Ie(Ve);const Xe=e=>e<256?je[e]:je[256+(e>>>7)],Je=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},$e=(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<{$e(e,n[2*t],n[2*t+1])},tt=(e,t)=>{let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1},nt=(e,t,n)=>{const r=new Array(16);let i,o,s=0;for(i=1;i<=Me;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]=tt(r[t]++,t))}},rt=e=>{let t;for(t=0;t{e.bi_valid>8?Je(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},ot=(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?et(e,i,t):(o=Ke[i],et(e,o+De+1,t),s=Pe[o],0!==s&&(i-=Be[o],$e(e,i,s)),r--,o=Xe(r),et(e,o,n),s=Ue[o],0!==s&&(r-=Ve[o],$e(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--)st(e,n,s);c=o;do{s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],st(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++,st(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<=Me;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),nt(n,u,e.bl_count)},ut=(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{$e(e,0+(r?1:0),3),it(e),Je(e,n),Je(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var _t=(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(ut(e,e.dyn_ltree,e.l_desc.max_code),ut(e,e.dyn_dtree,e.d_desc.max_code),ct(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*Fe[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?dt(e,t,n,r):4===e.strategy||o===i?($e(e,2+(r?1:0),3),at(e,qe,Ge)):($e(e,4+(r?1:0),3),((e,t,n,r)=>{let i;for($e(e,t-257,5),$e(e,n-1,5),$e(e,r-4,4),i=0;i{ht||((()=>{let e,t,n,r,i;const o=new Array(16);for(n=0,r=0;r<28;r++)for(Be[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*(Ke[n]+De+1)]++,e.dyn_dtree[2*Xe(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{$e(e,2,3),et(e,256,qe),(e=>{16===e.bi_valid?(Je(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 pt=(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 gt=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 vt=(e,t,n,r)=>{const i=gt,o=r+n;e^=-1;for(let n=r;n>>8^i[255&(e^t[n])];return-1^e},Et={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"},bt={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:yt,_tr_flush_block:wt,_tr_tally:St,_tr_align:kt}=ft,{Z_NO_FLUSH:Tt,Z_PARTIAL_FLUSH:Ct,Z_FULL_FLUSH:Ot,Z_FINISH:At,Z_BLOCK:Nt,Z_OK:Rt,Z_STREAM_END:It,Z_STREAM_ERROR:Dt,Z_DATA_ERROR:Lt,Z_BUF_ERROR:xt,Z_DEFAULT_COMPRESSION:Mt,Z_FILTERED:Pt,Z_HUFFMAN_ONLY:Ut,Z_RLE:zt,Z_FIXED:Ft,Z_DEFAULT_STRATEGY:qt,Z_UNKNOWN:Gt,Z_DEFLATED:jt}=bt,Kt=258,Bt=262,Vt=42,Zt=113,Ht=666,Wt=(e,t)=>(e.msg=Et[t],t),Qt=e=>2*e-(e>4?9:0),Yt=e=>{let t=e.length;for(;--t>=0;)e[t]=0},Xt=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 Jt=(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))},en=(e,t)=>{wt(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,$t(e.strm)},tn=(e,t)=>{e.pending_buf[e.pending++]=t},nn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},rn=(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=pt(e.adler,t,i,n):2===e.state.wrap&&(e.adler=vt(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)},on=(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-Bt?e.strstart-(e.w_size-Bt):0,u=e.window,l=e.w_mask,h=e.prev,d=e.strstart+Kt;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},sn=e=>{const t=e.w_size;let n,r,i;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Bt)&&(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),Xt(e),r+=t),0===e.strm.avail_in)break;if(n=rn(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=Jt(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=Jt(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,$t(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&&(rn(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&&(rn(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===At)&&t!==Tt&&0===e.strm.avail_in&&r<=i)&&(n=r>i?i:r,s=t===At&&0===e.strm.avail_in&&n===r?1:0,yt(e,e.block_start,n,s),e.block_start+=n,$t(e.strm)),s?3:1)},cn=(e,t)=>{let n,r;for(;;){if(e.lookahead=3&&(e.ins_h=Jt(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-Bt&&(e.match_length=on(e,n)),e.match_length>=3)if(r=St(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=Jt(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=Jt(e,e.ins_h,e.window[e.strstart+1]);else r=St(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(en(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===At?(en(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(en(e,!1),0===e.strm.avail_out)?1:2},un=(e,t)=>{let n,r,i;for(;;){if(e.lookahead=3&&(e.ins_h=Jt(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=St(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=Jt(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&&(en(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=St(e,0,e.window[e.strstart-1]),r&&en(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=St(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===At?(en(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(en(e,!1),0===e.strm.avail_out)?1:2};function ln(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 hn=[new ln(0,0,0,0,an),new ln(4,4,8,4,cn),new ln(4,5,16,8,cn),new ln(4,6,32,32,cn),new ln(4,4,16,16,un),new ln(8,16,32,32,un),new ln(8,16,128,128,un),new ln(8,32,128,256,un),new ln(32,128,258,1024,un),new ln(32,258,258,4096,un)];function dn(){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=jt,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),Yt(this.dyn_ltree),Yt(this.dyn_dtree),Yt(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),Yt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Yt(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 _n=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==Vt&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==Zt&&t.status!==Ht?1:0},fn=e=>{if(_n(e))return Wt(e,Dt);e.total_in=e.total_out=0,e.data_type=Gt;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?Vt:Zt,e.adler=2===t.wrap?0:1,t.last_flush=-2,mt(t),Rt},pn=e=>{const t=fn(e);var n;return t===Rt&&((n=e.state).window_size=2*n.w_size,Yt(n.head),n.max_lazy_match=hn[n.level].max_lazy,n.good_match=hn[n.level].good_length,n.nice_match=hn[n.level].nice_length,n.max_chain_length=hn[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},gn=(e,t,n,r,i,o)=>{if(!e)return Dt;let s=1;if(t===Mt&&(t=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),i<1||i>9||n!==jt||r<8||r>15||t<0||t>9||o<0||o>Ft||8===r&&1!==s)return Wt(e,Dt);8===r&&(r=9);const a=new dn;return e.state=a,a.strm=e,a.status=Vt,a.wrap=s,a.gzhead=null,a.w_bits=r,a.w_size=1<gn(e,t,jt,15,8,qt),deflateInit2:gn,deflateReset:pn,deflateResetKeep:fn,deflateSetHeader:(e,t)=>_n(e)||2!==e.state.wrap?Dt:(e.state.gzhead=t,Rt),deflate:(e,t)=>{if(_n(e)||t>Nt||t<0)return e?Wt(e,Dt):Dt;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===Ht&&t!==At)return Wt(e,0===e.avail_out?xt:Dt);const r=n.last_flush;if(n.last_flush=t,0!==n.pending){if($t(e),0===e.avail_out)return n.last_flush=-1,Rt}else if(0===e.avail_in&&Qt(t)<=Qt(r)&&t!==At)return Wt(e,xt);if(n.status===Ht&&0!==e.avail_in)return Wt(e,xt);if(n.status===Vt&&0===n.wrap&&(n.status=Zt),n.status===Vt){let t=jt+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=Ut||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,nn(n,t),0!==n.strstart&&(nn(n,e.adler>>>16),nn(n,65535&e.adler)),e.adler=1,n.status=Zt,$t(e),0!==n.pending)return n.last_flush=-1,Rt}if(57===n.status)if(e.adler=0,tn(n,31),tn(n,139),tn(n,8),n.gzhead)tn(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)),tn(n,255&n.gzhead.time),tn(n,n.gzhead.time>>8&255),tn(n,n.gzhead.time>>16&255),tn(n,n.gzhead.time>>24&255),tn(n,9===n.level?2:n.strategy>=Ut||n.level<2?4:0),tn(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(tn(n,255&n.gzhead.extra.length),tn(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=vt(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(tn(n,0),tn(n,0),tn(n,0),tn(n,0),tn(n,0),tn(n,9===n.level?2:n.strategy>=Ut||n.level<2?4:0),tn(n,3),n.status=Zt,$t(e),0!==n.pending)return n.last_flush=-1,Rt;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=vt(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=i,$t(e),0!==n.pending)return n.last_flush=-1,Rt;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=vt(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=vt(e.adler,n.pending_buf,n.pending-r,r)),$t(e),0!==n.pending)return n.last_flush=-1,Rt;r=0}t=n.gzindexr&&(e.adler=vt(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=vt(e.adler,n.pending_buf,n.pending-r,r)),$t(e),0!==n.pending)return n.last_flush=-1,Rt;r=0}t=n.gzindexr&&(e.adler=vt(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&&($t(e),0!==n.pending))return n.last_flush=-1,Rt;tn(n,255&e.adler),tn(n,e.adler>>8&255),e.adler=0}if(n.status=Zt,$t(e),0!==n.pending)return n.last_flush=-1,Rt}if(0!==e.avail_in||0!==n.lookahead||t!==Tt&&n.status!==Ht){let r=0===n.level?an(n,t):n.strategy===Ut?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(sn(e),0===e.lookahead)){if(t===Tt)return 1;break}if(e.match_length=0,n=St(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(en(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===At?(en(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(en(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===zt?((e,t)=>{let n,r,i,o;const s=e.window;for(;;){if(e.lookahead<=Kt){if(sn(e),e.lookahead<=Kt&&t===Tt)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+Kt;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=St(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=St(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(en(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===At?(en(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(en(e,!1),0===e.strm.avail_out)?1:2})(n,t):hn[n.level].func(n,t);if(3!==r&&4!==r||(n.status=Ht),1===r||3===r)return 0===e.avail_out&&(n.last_flush=-1),Rt;if(2===r&&(t===Ct?kt(n):t!==Nt&&(yt(n,0,0,!1),t===Ot&&(Yt(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),$t(e),0===e.avail_out))return n.last_flush=-1,Rt}return t!==At?Rt:n.wrap<=0?It:(2===n.wrap?(tn(n,255&e.adler),tn(n,e.adler>>8&255),tn(n,e.adler>>16&255),tn(n,e.adler>>24&255),tn(n,255&e.total_in),tn(n,e.total_in>>8&255),tn(n,e.total_in>>16&255),tn(n,e.total_in>>24&255)):(nn(n,e.adler>>>16),nn(n,65535&e.adler)),$t(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?Rt:It)},deflateEnd:e=>{if(_n(e))return Dt;const t=e.state.status;return e.state=null,t===Zt?Wt(e,Lt):Rt},deflateSetDictionary:(e,t)=>{let n=t.length;if(_n(e))return Dt;const r=e.state,i=r.wrap;if(2===i||1===i&&r.status!==Vt||r.lookahead)return Dt;if(1===i&&(e.adler=pt(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){0===i&&(Yt(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,sn(r);r.lookahead>=3;){let e=r.strstart,t=r.lookahead-2;do{r.ins_h=Jt(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,sn(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,Rt},deflateInfo:"pako deflate (from Nodeca project)"};const En=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var bn={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)En(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;yn[254]=yn[254]=1;var wn={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&&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+yn[e[n]]>t?n:t}};var Sn=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 kn=Object.prototype.toString,{Z_NO_FLUSH:Tn,Z_SYNC_FLUSH:Cn,Z_FULL_FLUSH:On,Z_FINISH:An,Z_OK:Nn,Z_STREAM_END:Rn,Z_DEFAULT_COMPRESSION:In,Z_DEFAULT_STRATEGY:Dn,Z_DEFLATED:Ln}=bt;function xn(e){this.options=bn.assign({level:In,method:Ln,chunkSize:16384,windowBits:15,memLevel:8,strategy:Dn},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 Sn,this.strm.avail_out=0;let n=vn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==Nn)throw new Error(Et[n]);if(t.header&&vn.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?wn.string2buf(t.dictionary):"[object ArrayBuffer]"===kn.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=vn.deflateSetDictionary(this.strm,e),n!==Nn)throw new Error(Et[n]);this._dict_set=!0}}function Mn(e,t){const n=new xn(t);if(n.push(e,!0),n.err)throw n.msg||Et[n.err];return n.result}xn.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?An:Tn,"string"==typeof e?n.input=wn.string2buf(e):"[object ArrayBuffer]"===kn.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===Cn||o===On)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(i=vn.deflate(n,o),i===Rn)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=vn.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Nn;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},xn.prototype.onData=function(e){this.chunks.push(e)},xn.prototype.onEnd=function(e){e===Nn&&(this.result=bn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Pn={Deflate:xn,deflate:Mn,deflateRaw:function(e,t){return(t=t||{}).raw=!0,Mn(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,Mn(e,t)},constants:bt};const Un=16209;var zn=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=Un;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=Un;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,R,I=null;for(p=0;p<=Fn;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=I[s[g]-f],R=T[s[g]-f]):(N=96,R=0),u=1<>y)+l]=A<<24|N<<16|R|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:Vn,Z_BLOCK:Zn,Z_TREES:Hn,Z_OK:Wn,Z_STREAM_END:Qn,Z_NEED_DICT:Yn,Z_STREAM_ERROR:Xn,Z_DATA_ERROR:Jn,Z_MEM_ERROR:$n,Z_BUF_ERROR:er,Z_DEFLATED:tr}=bt,nr=16180,rr=16190,ir=16191,or=16192,sr=16194,ar=16199,cr=16200,ur=16206,lr=16209,hr=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function dr(){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 _r=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},fr=e=>{if(_r(e))return Xn;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=nr,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,Wn},pr=e=>{if(_r(e))return Xn;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,fr(e)},gr=(e,t)=>{let n;if(_r(e))return Xn;const r=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Xn:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,pr(e))},vr=(e,t)=>{if(!e)return Xn;const n=new dr;e.state=n,n.strm=e,n.window=null,n.mode=nr;const r=gr(e,t);return r!==Wn&&(e.state=null),r};let Er,br,mr=!0;const yr=e=>{if(mr){Er=new Int32Array(512),br=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(Bn(1,e.lens,0,288,Er,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Bn(2,e.lens,0,32,br,0,e.work,{bits:5}),mr=!1}e.lencode=Er,e.lenbits=9,e.distcode=br,e.distbits=5},wr=(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.whavevr(e,15),inflateInit2:vr,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(_r(e)||!e.output||!e.input&&0!==e.avail_in)return Xn;n=e.state,n.mode===ir&&(n.mode=or),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=Wn;e:for(;;)switch(n.mode){case nr:if(0===n.wrap){n.mode=or;break}for(;l<16;){if(0===a)break e;a--,u+=r[o++]<>>8&255,n.check=vt(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=lr;break}if((15&u)!==tr){e.msg="unknown compression method",n.mode=lr;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=lr;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(T[0]=255&u,T[1]=u>>>8&255,n.check=vt(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=vt(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=vt(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=vt(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=vt(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=ir;break;case 16189:for(;l<32;){if(0===a)break e;a--,u+=r[o++]<>>=7&l,l-=7&l,n.mode=ur;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(yr(n),n.mode=ar,t===Hn){u>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=lr}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=lr;break}if(n.length=65535&u,u=0,l=0,n.mode=sr,t===Hn)break e;case sr: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=ir;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=lr;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=Bn(0,n.lens,0,19,n.lencode,0,n.work,C),n.lenbits=C.bits,S){e.msg="invalid code lengths set",n.mode=lr;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=lr;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=lr;break}for(;_--;)n.lens[n.have++]=w}}if(n.mode===lr)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=lr;break}if(n.lenbits=9,C={bits:n.lenbits},S=Bn(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=lr;break}if(n.distbits=6,n.distcode=n.distdyn,C={bits:n.distbits},S=Bn(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=lr;break}if(n.mode=ar,t===Hn)break e;case ar:n.mode=cr;case cr: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,zn(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===ir&&(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=ir;break}if(64&v){e.msg="invalid literal/length code",n.mode=lr;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=lr;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=lr;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=lr;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=cr);break;case 16205:if(0===c)break e;i[s++]=n.length,c--,n.mode=cr;break;case ur:if(n.wrap){for(;l<32;){if(0===a)break e;a--,u|=r[o++]<{if(_r(e))return Xn;let t=e.state;return t.window&&(t.window=null),e.state=null,Wn},inflateGetHeader:(e,t)=>{if(_r(e))return Xn;const n=e.state;return 0==(2&n.wrap)?Xn:(n.head=t,t.done=!1,Wn)},inflateSetDictionary:(e,t)=>{const n=t.length;let r,i,o;return _r(e)?Xn:(r=e.state,0!==r.wrap&&r.mode!==rr?Xn:r.mode===rr&&(i=1,i=pt(i,t,n,0),i!==r.check)?Jn:(o=wr(e,t,n,n),o?(r.mode=16210,$n):(r.havedict=1,Wn)))},inflateInfo:"pako inflate (from Nodeca project)"};var kr=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 Tr=Object.prototype.toString,{Z_NO_FLUSH:Cr,Z_FINISH:Or,Z_OK:Ar,Z_STREAM_END:Nr,Z_NEED_DICT:Rr,Z_STREAM_ERROR:Ir,Z_DATA_ERROR:Dr,Z_MEM_ERROR:Lr}=bt;function xr(e){this.options=bn.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 Sn,this.strm.avail_out=0;let n=Sr.inflateInit2(this.strm,t.windowBits);if(n!==Ar)throw new Error(Et[n]);if(this.header=new kr,Sr.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=wn.string2buf(t.dictionary):"[object ArrayBuffer]"===Tr.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=Sr.inflateSetDictionary(this.strm,t.dictionary),n!==Ar)))throw new Error(Et[n])}function Mr(e,t){const n=new xr(t);if(n.push(e),n.err)throw n.msg||Et[n.err];return n.result}xr.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?Or:Cr,"[object ArrayBuffer]"===Tr.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=Sr.inflate(n,s),o===Rr&&i&&(o=Sr.inflateSetDictionary(n,i),o===Ar?o=Sr.inflate(n,s):o===Dr&&(o=Rr));n.avail_in>0&&o===Nr&&n.state.wrap>0&&0!==e[n.next_in];)Sr.inflateReset(n),o=Sr.inflate(n,s);switch(o){case Ir:case Dr:case Rr:case Lr:return this.onEnd(o),this.ended=!0,!1}if(a=n.avail_out,n.next_out&&(0===n.avail_out||o===Nr))if("string"===this.options.to){let e=wn.utf8border(n.output,n.next_out),t=n.next_out-e,i=wn.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!==Ar||0!==a){if(o===Nr)return o=Sr.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},xr.prototype.onData=function(e){this.chunks.push(e)},xr.prototype.onEnd=function(e){e===Ar&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=bn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Pr={Inflate:xr,inflate:Mr,inflateRaw:function(e,t){return(t=t||{}).raw=!0,Mr(e,t)},ungzip:Mr,constants:bt};const{Deflate:Ur,deflate:zr,deflateRaw:Fr,gzip:qr}=Pn,{Inflate:Gr,inflate:jr,inflateRaw:Kr,ungzip:Br}=Pr;var Vr,Zr={Deflate:Ur,deflate:zr,deflateRaw:Fr,gzip:qr,Inflate:Gr,inflate:jr,inflateRaw:Kr,ungzip:Br,constants:bt};!function(e){e.CONNECTING="CONNECTING",e.OPEN="OPEN",e.CLOSED="CLOSED"}(Vr||(Vr={}));var Hr,Wr=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===Vr.OPEN},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"connectionState",{get:function(){if(this._ws)switch(this._ws.readyState){case 0:return Vr.CONNECTING;case 1:return Vr.OPEN}return Vr.CLOSED},enumerable:!1,configurable:!0}),n.prototype._handleMessage=function(e){var t=this;e.split("\n").forEach((function(e){if(e){var n=Ne.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 ke(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!==Vr.CLOSED?(e._ws.onopen=Re,e._ws.onmessage=Re,e._ws.onerror=Re,e._ws.onclose=function(){e.dispatch("close"),t()},e._ws.close(),e._ws=void 0):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),Qr=function(e){function n(t){var n,r=t.code,i=t.ackRequired,o=t.payload,s=void 0===o?{}: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:Z(),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),Yr=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),Xr=function(){var e=this;this.promise=new Promise((function(t,n){e.resolve=t,e.reject=n}))},Jr=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 Ae(e,{auth:n,sdkState:r,dispatcher:i,logger:o,useFetchCompat:a}),this.websocketClient=new Wr(e,{sdkState:r,dispatcher:i,logger:o}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&c._dispatcher.dispatch(new Yr(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(!this._sdkState.websocket)throw E.connectionRequired;if(t=new Xr,e.ackRequired){r=function(r,o){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(void 0,e)},reject:function(e){return r(e)}}),this.websocketClient.send(e)}catch(e){r(e)}}else try{this.websocketClient.send(e),t.resolve()}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 ye?[4,this._sendApiRequest(e)]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return e instanceof Qr?[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"}(Hr||(Hr={}));var $r=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),ei=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=Hr.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new Jr(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 $r){var t=e.stateType;switch(l._currentConnectionStateType=t,t){case Hr.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 Hr.INITIALIZED:case Hr.INTERNAL_DISCONNECTED:case Hr.EXTERNAL_DISCONNECTED:case Hr.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===Hr.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLazyCallActivated",{get:function(){return this._currentConnectionStateType===Hr.CONNECTING||this._currentConnectionStateType===Hr.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 Qr?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 Xr,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:case 7:return[3,9];case 4:return e instanceof ye?this._auth.hasSession?(this._logger.debug("send api request",e),[4,this.commandRouter.send(e)]):[3,6]:[3,8];case 6:if(this.isLazyCallActivated)return this._logger.debug("wait api request",e),t=new Xr,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 8:throw E.invalidCommand;case 9: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}(),ti="sendbird@devicetokens",ni=function(){function e(e){var t=e.type,n=e.token;this.type=t,this.token=n}return e.payloadify=function(e){return X(J({type:e.type,token:e.token}))},e}(),ri=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(te,"/").concat(n,"/session_key"),s.method=$.POST,s.params={token:r,expiring_session:!!o},s.requireAuth=!1,s}return t(n,e),n}(ye),ii=function(e){function n(t){var n=t.authToken,r=t.expiringSession,i=void 0===r||r,o=t.requestId,s=void 0===o?"":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}(Qr),oi=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}(we),si=function(e){function n(t,n,r){var i,o=this;return(o=e.call(this,t,"LOGI",r)||this).error=null,o.newKey=null,o.newKey=null!==(i=r.new_key)&&void 0!==i?i:null,o.error=r.error?new E(r.error):null,o}return t(n,e),n}(Ne),ai=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n}(Y),ci=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)}))]}))}))},ui=function(){function e(){}return e.prototype.calcTimeout=function(){return 0},e}(),li=function(e,t,n){return void 0===n&&(n=new ui),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 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 new ii({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(si),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 ri({userId:this._sdkState.userId,authToken:e,expiringSession:!0}),[4,li((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(oi).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;return o(this,(function(o){switch(o.label){case 0:if(this._currentConnectionStateType!==Hr.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?[4,this._receiveNewAuthToken()]:[3,9];case 4:return(i=o.sent())?(this.auth.authToken=i,[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 r=o.sent(),this._isSessionRelatedError(r)?t?[4,this._receiveNewAuthToken()]:[3,18]:[3,20];case 13:return(i=o.sent())?(this.auth.authToken=i,[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 r;case 19:return[3,21];case 20:throw r;case 21:return[3,22];case 22:return[2]}}))}))},n.prototype._receiveNewAuthToken=function(){var e=this,t=new Xr;return hi((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,_i.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(ti)]:[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(ti,{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(),_i.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,[4,this.saveDeviceToken()];case 1:return e.sent(),[2]}}))}))},n}(W),pi=function(){function e(){this.type=Hr.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}(),gi=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=Hr.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 wi,t)];case 2:return s.sent(),hi((function(){return i(r,void 0,void 0,(function(){return o(this,(function(t){return e.connectionHandlers.forEach((function(e){e.onDisconnected&&e.onDisconnected(n)})),[2]}))}))})),[2]}}))}))},n}(pi),vi=function(e){function n(){var t=e.call(this)||this;return t.type=Hr.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 yi({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 bi,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 gi,t)];case 1:return n.sent(),[2]}}))}))},n}(pi),Ei=function(e){function n(t){var n=t.autoReconnect,r=e.call(this)||this;return r.type=Hr.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 bi,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 yi({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 bi,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 vi,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 gi,t)];case 1:return n.sent(),[2]}}))}))},n}(pi),bi=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=Hr.RECONNECTING,t.name="reconnecting",t._callbacks=[],t}return t(n,e),n.prototype._halt=function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=void 0)},n.prototype._flushCallbacks=function(e){this._haltConnect=void 0,this._resetConnect=void 0,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 Xr,this._callbacks.push((function(e){return e?n.reject(e):n.resolve()})),hi((function(){return i(l,void 0,void 0,(function(){return o(this,(function(t){return e.connectionHandlers.forEach((function(e){e.onReconnectStarted&&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,li((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 mi,t)];case 3:return h.sent(),hi((function(){return i(l,void 0,void 0,(function(){return o(this,(function(t){return this._flushCallbacks(),e.connectionHandlers.forEach((function(e){e.onReconnectSucceeded&&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 Ei({autoReconnect:!1}),t)]:[3,6];case 5:h.sent(),h.label=6;case 6:return hi((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&&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 Xr,this._halt(E.connectionCanceled),e.cancelConnectForRetry(),this._callbacks.push((function(){var r=Date.now();e.changeState(new yi({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 Xr,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 Ei({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 vi,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 gi,t)];case 1:return n.sent(),[2]}}))}))},n}(pi),mi=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=Hr.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 bi,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 Ei({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 vi,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 gi,t)];case 1:return n.sent(),[2]}}))}))},n}(pi),yi=function(e){function n(t){var n=t.authToken,r=e.call(this)||this;return r.type=Hr.CONNECTING,r.name="connecting",r._authToken="",r._callbacks=[],r._authToken=n,r}return t(n,e),n.prototype._halt=function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=void 0)},n.prototype._flushCallbacks=function(e){this._haltConnect=void 0,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 Xr,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,li((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 mi,t)];case 3:return a.sent(),hi((function(){return i(s,void 0,void 0,(function(){return o(this,(function(t){return this._flushCallbacks(),e.connectionHandlers.forEach((function(t){t.onConnected&&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 wi,t)]:[3,7];case 6:a.sent(),a.label=7;case 7:return hi((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 Xr,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,a=void 0!==s&&s;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 Ei({autoReconnect:a}),t)]:[3,2];case 1:return n.sent(),[3,4];case 2:return[4,e.changeState(new gi,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 vi,t)]:[3,2];case 1:return n.sent(),[3,4];case 2:return[4,e.changeState(new gi,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 gi,t)];case 1:return n.sent(),[2]}}))}))},n}(pi),wi=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=Hr.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 yi({authToken:t}),n)];case 1:return r.sent(),[2]}}))}))},n}(pi),Si=function(e){function n(){return e.call(this,{code:"PING",payload:{id:Date.now(),active:1},ackRequired:!1})||this}return t(n,e),n}(Qr),ki=function(){function e(e){var t=e.pingDelegate,n=e.sdkState,r=e.logger;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;if(!this.sdkState.websocket)throw E.connectionRequired;var n=new Si;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()}),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=void 0),this.pingDelegate.error()}return n},e.prototype.pong=function(){this._logger.debug("pinger.pong()"),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)},e.prototype.refreshTimer=function(){var e,t=this;if(!this.sdkState.websocket)throw E.connectionRequired;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=void 0),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)},e}(),Ti=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(J({last_updated_at:e.lastUpdatedAt}))},e}(),Ci=1048576,Oi=5,Ai=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*Ci: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 Ti(null!==(o=e.uikit_config)&&void 0!==o?o:{})}return e.payloadify=function(e){return X(J({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/Ci,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,uikit_config:e.uikitConfigInfo?Ti.payloadify(e.uikitConfigInfo):null}))},e}(),Ni=function(){function e(e){this._iid="",this._iid=e}return e.payloadify=function(e){return{}},e}(),Ri=function(e){function n(t){var n=t.userId,r=t.metadata,i=e.call(this)||this;return i.method=$.POST,i.path="".concat(te,"/").concat(n,"/metadata"),i.params={metadata:r},i}return t(n,e),n}(ye),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}(we),Di=function(e){function n(t){var n=t.userId,r=t.metadata,i=t.upsert,o=e.call(this)||this;return o.method=$.PUT,o.path="".concat(te,"/").concat(n,"/metadata"),o.params={metadata:r,upsert:i},o}return t(n,e),n}(ye),Li=function(e){function n(t,n){var r=e.call(this,t,n)||this;return r.metadata=n,r}return t(n,e),n}(we),xi=function(e){function n(t){var n=t.userId,r=t.metadataKey,i=e.call(this)||this;return i.method=$.DELETE,i.path="".concat(te,"/").concat(n,"/metadata/").concat(r),i}return t(n,e),n}(ye);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(we);var Mi=function(e){function n(t){var n=t.userId,r=e.call(this)||this;return r.method=$.DELETE,r.path="".concat(te,"/").concat(n,"/metadata"),r}return t(n,e),n}(ye);!function(e){function n(){return null!==e&&e.apply(this,arguments)||this}t(n,e)}(we);var Pi,Ui=function(e,t){var n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},zi=function(e,t){var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},Fi=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"}(Pi||(Pi={}));var qi,Gi=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=Pi.NON_AVAILABLE,S(Pi,n.is_online)?v.connectionStatus=n.is_online:w("boolean",n.is_online)&&(v.connectionStatus=n.is_online?Pi.ONLINE:Pi.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 X(J(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})))},Object.defineProperty(r.prototype,"profileUrl",{get:function(){var e=no.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 Ui(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 Fi(this._isValidMetaData(e)).throw(E.invalidParameters),t=no.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new Ri({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 Fi(this._isValidMetaData(e)).throw(E.invalidParameters),n=no.of(this._iid),r=n.sdkState,i=n.requestQueue,s=new Di({userId:r.userId,metadata:e,upsert:t}),[4,i.send(s)];case 1:return a=o.sent(),c=a.as(Li).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 Fi(w("string",e)).throw(E.invalidParameters),t=no.of(this._iid),n=t.sdkState,r=t.requestQueue,i=new xi({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=no.of(this._iid),t=e.sdkState,n=e.requestQueue,r=new Mi({userId:t.userId}),[4,n.send(r)];case 1:return i.sent(),this.metaData={},[2]}}))}))},r}(Ni),ji=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),Ki=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 Ai(t),this.user=new Gi(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 X(J(n(n(n({},Gi.payloadify(e.user)),Ai.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=no.of(this._iid);r.sdkState.websocket&&(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 ji({userProfile:this}))},e}(),Bi=function(e){function r(t,n,r){var i,o,s,a=this;return(a=e.call(this,t,n,r)||this).error=null,a.userProfile=new Ki(t,r),a.deviceTokenLastDeletedAt=null!==(i=r.device_token_last_deleted_at)&&void 0!==i?i:0,a.key=null!==(o=r.key)&&void 0!==o?o:"",a.ekey=null!==(s=r.ekey)&&void 0!==s?s:"",a.error=r.error?new E(r):null,a}return t(r,e),r.asError=function(e){return new r("","LOGI",n({user_id:"",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=no.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}(Ne),Vi=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,i=n.sdkState,o=n.cacheContext,s=n.connectionHandlers,a=n.sessionManager,c=n.websocketClient,u=n.dispatcher,l=n.logger,h=n.entryState,d=void 0===h?new wi:h,_=this;return(_=e.call(this)||this)._stateUpdatedAt=0,_._connectingAt=0,_._connectionRequestQueue=[],_._iid=t,_.sdkState=i,_.cacheContext=o,_.connectionHandlers=s,_._sessionManager=a,_._websocketClient=c,_._dispatcher=u,_._logger=l,_._currentState=d,(null===(r=_.sdkState.websocket)||void 0===r?void 0:r.pingerDisabled)||(_._pinger=new ki({pingDelegate:{send:function(e){return _._websocketClient.send(e)},error:function(e){return _._websocketClient.error(e)}},sdkState:_.sdkState,logger:l})),_._websocketClient.on("open",(function(){_._tryResolveConnectionRequest()})).on("message",(function(e){if("LOGI"===e.code)_.clearLoginTimer(),_._dispatcher.dispatch(e.as(Bi))})).on("ping-refresh",(function(){var e;return null===(e=_._pinger)||void 0===e?void 0:e.refreshTimer()})).on("pong",(function(){var e;return null===(e=_._pinger)||void 0===e?void 0:e.pong()})).on("error",(function(){var e;return null===(e=_._pinger)||void 0===e?void 0:e.stop()})).on("close",(function(){_._logiProcessingTimer=setTimeout((function(){_._logiProcessingTimer=void 0,_._unresolvedLogi||_._rejectConnectionRequest(E.networkError)}),500)})),_._dispatcher.on((function(e){e instanceof Bi&&(_._unresolvedLogi=e,_._tryResolveConnectionRequest())})),_}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 $r({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=void 0,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===(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=void 0,(t.error.isSessionKeyExpiredError||t.error.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new ke({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,n,r;void 0===e&&(e="");var i=this.sdkState,o=i.appId,s=i.appVersion,a=i.userId;i.extensions;var c=this.cacheContext.localCacheEnabled,u=this._sessionManager.auth,l=null===(t=this.sdkState.websocket)||void 0===t?void 0:t.compression,d=null!==(n=this.sdkState.extensions)&&void 0!==n?n:{},_=!!d.sb_uikit,f=d.sb_syncmanager?"s".concat(d.sb_syncmanager):"",p=d.sb_uikit?"u".concat(d.sb_uikit):"",g="JS/c".concat(h.SDK_VERSION,"/").concat(f,"/").concat(p);return"".concat(null===(r=this.sdkState.websocket)||void 0===r?void 0:r.host,"/?p=JS&pv=").concat(encodeURIComponent(h.OS_VERSION),"&sv=").concat(encodeURIComponent(h.SDK_VERSION),"&ai=").concat(o).concat(s?"&av=".concat(s):"").concat(u.hasSession?"&key=".concat(encodeURIComponent(u.sessionKey)):"&user_id=".concat(encodeURIComponent(a),"&access_token=").concat(encodeURIComponent(e)),"&pmce=").concat(l?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(g,"&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(c?1:0,"&include_poll_details=1").concat(_?"&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 Vi({request:t,features:n,options:i}))},n.prototype._statLogConnection=function(e){var t;this._dispatcher.dispatch(new Te(new Ce({type:me.WEBSOCKET_CONNECT,data:{host_url:null===(t=this.sdkState.websocket)||void 0===t?void 0:t.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){var t;return void 0===e&&(e=""),i(this,void 0,void 0,(function(){var n,r,i=this;return o(this,(function(o){return this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=void 0,this._rejectConnectionRequest(E.connectionCanceled)),n=this._url(e),r=new Xr,this._connectionRequestQueue.push(r),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){i._loginTimer=void 0,i._rejectConnectionRequest(E.loginTimeout)}),null===(t=this.sdkState.websocket)||void 0===t?void 0:t.responseTimeout),e&&(this._sessionManager.auth.authToken=e),this._websocketClient.connect(n)),[2,r.promise]}))}))},n.prototype.cancelConnectForRetry=function(){this._dispatcher.dispatch(Bi.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=void 0,this._unresolvedLogi=void 0,[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=void 0)},n}(W),Hi=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._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=void 0),this._websocketEventDispatcherContext&&(this._websocketEventDispatcherContext.close(),this._websocketEventDispatcherContext=void 0)},Object.defineProperty(e.prototype,"isConnected",{get:function(){return this._context.currentState.type===Hr.CONNECTED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isConnecting",{get:function(){var e=this._context.currentState;return e.type===Hr.CONNECTING||e.type===Hr.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 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}(),Wi=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}(Ce),Qi=function(e){function n(t){var n=t.deviceId,r=t.statLogs,i=e.call(this)||this;return i.method=$.POST,i.path="".concat(fe),i.params={device_id:n,log_entries:r.map((function(e){return Ce.payloadify(e)}))},i}return t(n,e),n}(ye),Yi=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[_]=Yi(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"}(qi||(qi={}));var Xi,Ji=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=qi.PENDING,h.isFlushing=!1,h.generation=1,h.lastFlushedAt=0,h._collectRequestStat=!0,h._collectFeatureLocalCacheStat=!0,h.deviceId=Z(),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===qi.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===me.API_RESULT||e.type===me.WEBSOCKET_CONNECT}))),!1)),this._collectFeatureLocalCacheStat&&e.push.apply(e,c([],a(this.queue.filter((function(e){return e.type===me.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!==qi.ENABLED?[3,2]:[4,this.cacheContext.preference.set(this.key,{deviceId:this.deviceId,statLogs:this.queue.map((function(e){return Ce.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 Wi){var t=new Date,n=a([e.date.getFullYear(),t.getFullYear()],2),r=n[0],i=n[1];if(r0?(r=new Qi({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=qi.DISABLED,[3,8];case 7:i.code===u.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=qi.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 Ce({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,ci(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 Te){var t=e.statLog;r.put(t)}else if(e instanceof Vi){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?qi.ENABLED:qi.COLLECT_ONLY:r.enabledState=qi.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===qi.DISABLED?[3,3]:(e instanceof Wi?this._collectFeatureLocalCacheStat&&(t=a(this.queue.filter((function(t){return t instanceof Wi&&t.key===e.key})),1),(n=t[0])?n.data=Yi(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=void 0)},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"}(Xi||(Xi={}));var $i,eo=function(){function e(){this.level=Xi.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 X(J(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 uo.payloadify(e)})),created_by:t.createdBy,allow_user_suggestion:t.allowUserSuggestion,allow_multiple_votes:t.allowMultipleVotes,voted_option_ids:t.votedPollOptionIds})))},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 Ui(this)},r}(Ni);!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"}(io||(io={}));var ho=function(e){return e.startsWith("EVENT_")||e===io.SYNC_MESSAGE_FILL||e===io.SYNC_MESSAGE_CHANGELOGS||e===io.SYNC_POLL_CHANGELOGS},_o=function(e){function n(t){var n=t.messages,r=t.source,i=t.isWebSocketEventComing,o=void 0!==i&&i,s=e.call(this)||this;return s.messages=n,s.source=r,s.isWebSocketEventComing=o,s}return t(n,e),n}(Y),fo=function(e){function n(t){var n=t.messageIds,r=t.source,i=t.isWebSocketEventComing,o=void 0!==i&&i,s=e.call(this)||this;return s.messageIds=n,s.source=r,s.isWebSocketEventComing=o,s}return t(n,e),n}(Y),po=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),go=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),vo=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),Eo=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),bo=function(){function e(e,t){var n;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}(),mo=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}(bo);export{ne as $,$ as A,bo as B,Vr as C,Yr as D,W as E,ji as F,Ki as G,ke as H,d as I,di as J,s as K,B as L,S as M,_ as N,p as O,f as P,x as Q,K as R,E as S,Xi as T,Gi as U,no as V,Ne as W,M as X,Ti as Y,Pi as Z,t as _,w as a,Ni as a0,y as a1,P as a2,Ui as a3,F as a4,j as a5,C as a6,U as a7,lo as a8,G as a9,ce as aA,Ee as aB,z as aC,v as aD,Eo as aE,N as aF,vo as aG,po as aH,ie as aI,de as aJ,oo as aK,ho as aL,Wi as aM,me as aN,li as aO,so as aP,se as aQ,oe as aR,Qr as aa,pe as ab,ve as ac,u as ad,ci as ae,Xr as af,q as ag,re as ah,io as ai,_o as aj,fo as ak,ae as al,mo as am,ro as an,uo as ao,$i as ap,Y as aq,O as ar,I as as,r as at,he as au,co as av,ao as aw,go as ax,Oi as ay,ge as az,i as b,o as c,te as d,X as e,ye as f,n as g,we as h,A as i,le as j,ue as k,_e as l,T as m,Re as n,R as o,Z as p,Oe as q,c as r,a as s,Fi as t,J as u,l as v,zi as w,$r as x,Hr as y,hi as z}; diff --git a/lib/__bundle-84f74e8d.js b/lib/__bundle-80fd264e.js similarity index 83% rename from lib/__bundle-84f74e8d.js rename to lib/__bundle-80fd264e.js index ec3c662..3d2cd52 100644 --- a/lib/__bundle-84f74e8d.js +++ b/lib/__bundle-80fd264e.js @@ -1 +1 @@ -import{_ as e,A as t,$ as n,e as s,f as a,h as i,u as r,g as l,U as u,a0 as o,m as d,a as c,M as h,r as p,s as m,K as f,X as g,a1 as y,a2 as _,a3 as v,Q as I,a4 as M,a5 as T,a6 as S,a7 as A,b,c as U,t as E,S as w,a8 as F,V as q,a9 as D,aa as N,ab as P,ac as C,W as R,x as L,y as O,ad as k,ae as z,i as x,af as Q,ag as G,ah as B,w as j,ai as H,aj as W,ak as K,n as V,al as X,B as $,am as J,an as Y}from"./__bundle-75942676.js";var Z,ee=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&&c("number",r)&&(this.key=a,this.userIds=i,this.updatedAt=r);var l={};try{for(var u=f(this.userIds),o=u.next();!o.done;o=u.next()){l[o.value]=this.updatedAt}}catch(e){t={error:e}}finally{try{o&&!o.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 s(r({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}))},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 Z.ADD:t<0&&this.userIds.push(e.userId);break;case Z.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}},e}(),le=function(){function e(e){this.key=e.key,this.value=d("string",e.value)?p([],m(e.value),!1):[]}return e.payloadify=function(e){var t;return s(r({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}))},e}(),ue=function(){function e(e){this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,this.url=e.url,e.secure_url&&(this.secureUrl=e.secure_url),e.type&&(this.type=e.type),e.width&&(this.width=e.width),e.height&&(this.height=e.height),e.alt&&(this.alt=e.alt)}return e.payloadify=function(e){var t,n;return s(r({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}))},e}(),oe=function(){function e(e){this.title=null,this.url=null,this.description=null,this.defaultImage=null,e["og:title"]&&(this.title=e["og:title"]),e["og:url"]&&(this.url=e["og:url"]),e["og:description"]&&(this.description=e["og:description"]),e["og:image"]&&(this.defaultImage=new ue(e["og:image"]))}return e.payloadify=function(e){return s(r({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?ue.payloadify(e.defaultImage):null}))},e}(),de=function(){function e(e){var t,n;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 s(r({name:e.name,volume:e.volume}))},e}(),ce=function(t){function n(e,n){var s,a=this;return(a=t.call(this,e,n)||this).isBlockedByMe=!1,a.role=h(g,n.role)?n.role:g.NONE,a.isBlockedByMe=null!==(s=n.is_blocked_by_me)&&void 0!==s&&s,a}return e(n,t),n.payloadify=function(e){return s(r(l(l({},t.payloadify.call(this,e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})))},n}(u);!function(e){e.PENDING="pending",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled"}(se||(se={})),function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(ae||(ae={}));var he=function(e){switch(e){case _.BASE:return"";case _.USER:return"MESG";case _.FILE:return"FILE";case _.ADMIN:return"ADMM"}},pe=function(t){function n(e,n){var s,a,i,r,l,o,d,c,p,m,f,g,y,v,T,S,A=this;(A=t.call(this,e)||this).channelType=I.BASE,A.parentMessage=null,A.silent=!1,A.isOperatorMessage=!1,A.messageType=_.BASE,A.mentionType=null,A.threadInfo=null,A.reactions=[],A.metaArrays=[],A.appleCriticalAlertOptions=null,A.createdAt=0,A.updatedAt=0,A.scheduledInfo=null,A.extendedMessage={},A._isContinuousMessages=!1,A._scheduledStatus=null,A.messageId=null!==(a=null!==(s=n.msg_id)&&void 0!==s?s:n.message_id)&&void 0!==a?a:0,A.channelUrl=n.channel_url,A.channelType=h(I,n.channel_type)?n.channel_type:I.GROUP,n.channel&&(n.channel.channel_url&&(A.channelUrl=n.channel.channel_url),n.channel.channel_type&&(A.channelType=n.channel.channel_type)),A.parentMessageId=null!==(i="string"==typeof n.parent_message_id?parseInt(n.parent_message_id):n.parent_message_id)&&void 0!==i?i:0,A.data=null!==(r=n.data)&&void 0!==r?r:"",A.customType=null!==(l=n.custom_type)&&void 0!==l?l:"",A.mentionType=h(M,n.mention_type)?n.mention_type:null,A.mentionedUsers=n.mentioned_users?n.mentioned_users.map((function(e){return new u(A._iid,e)})):null,A.mentionedUserIds=null!==(o=n.mentioned_user_ids)&&void 0!==o?o:null,A.mentionedUsers&&!A.mentionedUserIds&&(A.mentionedUserIds=A.mentionedUsers.map((function(e){return e.userId}))),A.mentionedMessageTemplate=null!==(d=n.mentioned_message_template)&&void 0!==d?d:"",A.threadInfo=n.thread_info?new ne(A._iid,n.thread_info):null,A.reactions=n.reactions?n.reactions.map((function(e){return new re(e)})):[];var b=null!==(c=n.metaarray)&&void 0!==c?c:{},U=null!==(p=n.metaarray_key_order)&&void 0!==p?p:Object.keys(b).sort((function(e,t){return e.localeCompare(t)}));A.metaArrays=[];for(var E=0;E=t)return this.parentMessage=e,!0}return!1},n}(o),me=function(t){function n(e,n){var s,a,i,r,l=this;if((l=t.call(this,e,n)||this).reqId="",l.replyToChannel=!1,l.errorCode=0,l.sender=n.user?new ce(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&&h(T,n.request_state)&&(l.sendingStatus=n.request_state),!l.sendingStatus)if(l.messageId>0)l.sendingStatus=T.SUCCEEDED;else if(l.scheduledInfo)switch(n.scheduled_status&&(l._scheduledStatus=n.scheduled_status),n.scheduled_status){case ae.SENT:case ae.IN_QUEUE:l.sendingStatus=T.SUCCEEDED;break;case ae.PENDING:l.sendingStatus=T.SCHEDULED;break;case ae.FAILED:case ae.REMOVED:l.sendingStatus=T.FAILED;break;case ae.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 s(r(l(l({},t.payloadify.call(this,e)),{user:ce.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode})))},Object.defineProperty(n.prototype,"isResendable",{get:function(){return this.sendingStatus===T.FAILED&&S(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}(pe),fe=function(){function e(e){var t,n;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 s(r({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}))},Object.defineProperty(e.prototype,"plainUrl",{get:function(){return this.url.split("?auth=")[0]},enumerable:!1,configurable:!0}),e}(),ge={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:A.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},ye=function(e){return c("number",e.prevResultSize)&&c("number",e.nextResultSize)&&c("boolean",e.isInclusive)&&c("boolean",e.reverse)&&c("string",e.messageTypeFilter)&&h(A,e.messageTypeFilter)&&d("string",e.customTypesFilter,!0)&&d("string",e.senderUserIdsFilter,!0)&&c("boolean",e.includeMetaArray)&&c("boolean",e.includeReactions)&&c("boolean",e.includeParentMessageInfo)},_e=function(t){function n(e,n){var a,i,u,o,d=this;if((d=t.call(this,e,n)||this).translations={},d.message=null!==(a=n.message)&&void 0!==a?a:"",d.messageType=_.ADMIN,d.translations=null!==(i=n.translations)&&void 0!==i?i:{},n.parent_message_info){var c=n.parent_message_info;d.parentMessage=Ae(e,s(r(l(l({},c),{message_id:d.parentMessageId,channel_url:d.channelUrl,channel_type:d.channelType,file:c.file,url:null===(u=c.file)||void 0===u?void 0:u.url,require_auth:null===(o=c.file)||void 0===o?void 0:o.require_auth}))))}return d}return e(n,t),n.payloadify=function(e){return s(r(l(l({},t.payloadify.call(this,e)),{message:e.message,translations:e.translations,parent_message_info:e.parentMessage?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=l(l({},ge),t),E(this.messageId>0&&c("number",e)&&ye(n)).throw(w.invalidParameters),[4,Ke.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,s.sent()]}}))}))},n}(pe),ve=function(){function e(e){var t,n;this.detail={},this.type=null!==(t=e.type)&&void 0!==t?t:"",this.vendor=null!==(n=e.vendor)&&void 0!==n?n:"",e.detail&&c("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}return e.payloadify=function(e){return s(r({type:e.type,vendor:e.vendor,detail:e.detail}))},e}(),Ie=function(t){function n(e,n){var a,i,u,o,d,c,h,p=this;if((p=t.call(this,e,n)||this).message="",p.messageParams=null,p.translations={},p.translationTargetLanguages=[],p.messageSurvivalSeconds=-1,p.plugins=[],p._poll=null,p.message=n.message,p.messageType=_.USER,p.translations=null!==(u=n.translations)&&void 0!==u?u:{},p.translationTargetLanguages=null!==(o=n.target_langs)&&void 0!==o?o:[],0===Object.keys(p.translations).length&&p.translationTargetLanguages.length>0)try{for(var m=f(p.translationTargetLanguages),g=m.next();!g.done;g=m.next()){var y=g.value;p.translations[y]=""}}catch(e){a={error:e}}finally{try{g&&!g.done&&(i=m.return)&&i.call(m)}finally{if(a)throw a.error}}if(p.messageSurvivalSeconds=null!==(d=n.message_survival_seconds)&&void 0!==d?d:-1,p.plugins=n.plugins?n.plugins.map((function(e){return new ve(e)})):[],p._poll=n.poll?new F(p._iid,n.poll):null,n.parent_message_info){var v=n.parent_message_info;p.parentMessage=Ae(e,s(r(l(l({},v),{created_at:v.ts,message_id:p.parentMessageId,channel_url:p.channelUrl,channel_type:p.channelType,file:v.file,url:null===(c=v.file)||void 0===c?void 0:c.url,require_auth:null===(h=v.file)||void 0===h?void 0:h.require_auth}))))}return p}return e(n,t),n.payloadify=function(e){return s(r(l(l({},t.payloadify.call(this,e)),{message:e.message,translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((function(e){return ve.payloadify(e)})),poll:e._poll?F.payloadify(e._poll):null,parent_message_info:e.parentMessage?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=l(l({},ge),t),E(this.messageId>0&&c("number",e)&&ye(n)).throw(w.invalidParameters),[4,Ke.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}(me),Me=function(t){function n(e,n){var s,a,i,r,u,o=this;(o=t.call(this,e)||this).plainUrl="",o.fileName=null,o.mimeType=null,o.fileSize=0,o.thumbnails=[],o._requireAuth=!1,o.plainUrl=null!==(s=n.url)&&void 0!==s?s:"",o.fileName=null!==(a=n.file_name)&&void 0!==a?a:null,o.mimeType=null!==(i=n.file_type)&&void 0!==i?i:null,o.fileSize=null!==(r=n.file_size)&&void 0!==r?r:0,o._requireAuth=null!==(u=n.require_auth)&&void 0!==u&&u;var d=q.of(o._iid).sessionManager;return o.thumbnails=n.thumbnails?n.thumbnails.map((function(e){return new fe(l(l({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(o._requireAuth?"?auth=".concat(d.ekey):"")}))})):[],o}return e(n,t),n.payloadify=function(e){var t;return s(r({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=q.of(this._iid).sessionManager;return this._requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),n}(o),Te=function(t){function n(e,n){var a,i,u,o,d,c=this;if((c=t.call(this,e,n)||this).messageParams=null,c.fileInfoList=[],c.messageSurvivalSeconds=-1,c.messageType=_.FILE,c.fileInfoList=null!==(i=null===(a=n.files)||void 0===a?void 0:a.map((function(t){return new Me(e,t)})))&&void 0!==i?i:[],c.messageSurvivalSeconds=null!==(u=n.message_survival_seconds)&&void 0!==u?u:-1,n.parent_message_info){var h=n.parent_message_info;c.parentMessage=Ae(e,s(r(l(l({},h),{created_at:h.ts,message_id:c.parentMessageId,channel_url:c.channelUrl,channel_type:c.channelType,file:h.file,url:null===(o=h.file)||void 0===o?void 0:o.url,require_auth:null===(d=h.file)||void 0===d?void 0:d.require_auth}))))}return c}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=l(l({},ge),t),E(this.messageId>0&&c("number",e)&&ye(n)).throw(w.invalidParameters),[4,Ke.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,s.sent()]}}))}))},n.payloadify=function(e){return s(r(l(l({},t.payloadify.call(this,e)),{files:e.fileInfoList&&e.fileInfoList&&Array.isArray(e.fileInfoList)?e.fileInfoList.map((function(e){return Me.payloadify(e)})):null,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?t._getParentMessageInfoPayload.call(this,e.parentMessage):null})))},n._isMultipleFilesMessagePayload=function(e){var t=e.files;return Array.isArray(t)&&t.length>=2},n._isMultipleFilesMessageSerializedData=function(e){var t=e.fileInfoList;return Array.isArray(t)},n}(me),Se=function(e){switch(e.messageType){case _.USER:return Ie.payloadify(e);case _.FILE:return e.fileInfoList?Te.payloadify(e):be.payloadify(e);case _.ADMIN:return _e.payloadify(e);default:throw w.unknown}},Ae=function(e,t){switch(t.type){case"MESG":return new Ie(e,t);case"FILE":return Te._isMultipleFilesMessagePayload(t)?new Te(e,t):new be(e,t);case"ADMM":case"BRDM":return new _e(e,t)}throw w.unknown},be=function(t){function n(e,n){var a,i,u,o,d,c,h,p,m,f,g,y,v,I,M=this;(M=t.call(this,e,n)||this).messageParams=null,M.plainUrl="",M.requireAuth=!1,M.thumbnails=[],M.messageSurvivalSeconds=-1,M.messageType=_.FILE;var T=n.file;M.plainUrl=(null!==(i=null!==(a=null==T?void 0:T.url)&&void 0!==a?a:n.url)&&void 0!==i?i:"").split("?auth=")[0],M.name=null!==(o=null!==(u=null==T?void 0:T.name)&&void 0!==u?u:n.name)&&void 0!==o?o:"File",M.size=null!==(c=null!==(d=null==T?void 0:T.size)&&void 0!==d?d:n.size)&&void 0!==c?c:0,M.data=null!==(p=null!==(h=null==T?void 0:T.data)&&void 0!==h?h:n.custom)&&void 0!==p?p:"",M.type=T?null!==(m=T.type)&&void 0!==m?m:"":null!==(f=n.type)&&void 0!==f?f:"";var S=q.of(M._iid).sessionManager;if(M.requireAuth=null!==(g=n.require_auth)&&void 0!==g&&g,M.thumbnails=n.thumbnails?n.thumbnails.map((function(e){return new fe(l(l({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(M.requireAuth?"?auth=".concat(S.ekey):"")}))})):[],M.messageSurvivalSeconds=null!==(y=n.message_survival_seconds)&&void 0!==y?y:-1,n.parent_message_info){var A=n.parent_message_info;M.parentMessage=Ae(e,s(r(l(l({},A),{created_at:A.ts,message_id:M.parentMessageId,channel_url:M.channelUrl,channel_type:M.channelType,file:A.file,url:null===(v=A.file)||void 0===v?void 0:v.url,require_auth:null===(I=A.file)||void 0===I?void 0:I.require_auth}))))}return M}return e(n,t),n.payloadify=function(e){var n;return s(r(l(l({},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:e.parentMessage?t._getParentMessageInfoPayload.call(this,e.parentMessage):null})))},Object.defineProperty(n.prototype,"url",{get:function(){var e=q.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=l(l({},ge),t),E(this.messageId>0&&c("number",e)&&ye(n)).throw(w.invalidParameters),[4,Ke.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,s.sent()]}}))}))},n}(me),Ue=function(t){function n(e){var n,a,i,l=[];return e.mentionType===M.USERS&&(e.mentionedUserIds?l=e.mentionedUserIds:e.mentionedUsers&&(l=e.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"FILE",ackRequired:!0,payload:s(r({channel_url:e.channelUrl,files:e.files?qe(e.files):null,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:l,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==D.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions?de.payloadify(e.appleCriticalAlertOptions):null,silent:e.silent,reply_to_channel:e.isReplyToChannel,parent_message_id:e.parentMessageId?e.parentMessageId:null,req_id:e.reqId,pin_message:e.isPinnedMessage}))})||this}return e(n,t),n}(N),Ee=function(n){function a(e){var a,i,l=this;l=n.call(this)||this;var u=[];return e.mentionType===M.USERS&&(e.mentionedUserIds?u=e.mentionedUserIds:e.mentionedUsers&&(u=e.mentionedUsers.map((function(e){return e.userId})))),l.method=t.POST,l.path="".concat(P(e.channelType),"/").concat(encodeURIComponent(e.channelUrl),"/messages"),l.params=s(r({message_type:_.FILE,user_id:e.userId,files:e.files?qe(e.files):null,url:e.fileUrl,mention_type:e.mentionType,mentioned_user_ids:u,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 fe.payloadify(e)})),require_auth:e.requireAuth,sorted_metaarray:null===(i=e.metaArrays)||void 0===i?void 0:i.map((function(e){return le.payloadify(e)})),push_option:e.pushNotificationDeliveryOption,parent_message_id:e.parentMessageId?e.parentMessageId:null,apple_critical_alert_options:e.appleCriticalAlertOptions?de.payloadify(e.appleCriticalAlertOptions):null,reply_to_channel:e.isReplyToChannel,req_id:e.reqId,pin_message:e.isPinnedMessage})),l}return e(a,n),a}(a),we=function(t){function n(e,n,s){var a,i,r,l,u=this;(u=t.call(this,e,"FILE",s)||this).message=s.files&&s.files.length>=2?new Te(e,s):new be(e,s);var o=q.of(e).sdkState;return u.isMentioned=C(u.message.mentionType,null!==(r=null!==(a=u.message.mentionedUserIds)&&void 0!==a?a:null===(i=u.message.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})))&&void 0!==r?r:[],o.userId),u.forceUpdateLastMessage=null!==(l=s.force_update_last_message)&&void 0!==l&&l,u}return e(n,t),n}(R),Fe=function(t){function n(e,n){var s,a,i,r,l=this;(l=t.call(this,e,n)||this).message=n.files&&n.files.length>=2?new Te(e,n):new be(e,n);var u=q.of(e).sdkState;return l.isMentioned=C(l.message.mentionType,null!==(i=null!==(s=l.message.mentionedUserIds)&&void 0!==s?s:null===(a=l.message.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})))&&void 0!==i?i:[],u.userId),l.forceUpdateLastMessage=null!==(r=n.force_update_last_message)&&void 0!==r&&r,l}return e(n,t),n}(i);function qe(e){return e.map((function(e){var t,n;return s(r({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 fe.payloadify(e)})),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth}))}))}var De;!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"}(De||(De={}));var Ne=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._iid=e,this._sdkState=n,this._requestQueue=a,this._cacheContext=r,this._dispatcher=s,this._dispatcher.on((function(e){e instanceof L&&(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(we).message];case 2:return s=new Ee(l(l({},n),{userId:this._sdkState.userId})),[4,this._requestQueue.send(s)];case 3:return a=i.sent(),[2,a.as(Fe).message]}}))}))},e.prototype._createSendFileMessageRequestParams=function(e,t){var n=l(l({},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){var t;return b(this,void 0,void 0,(function(){var n,s,a,i,r,l,u,o,d,c,h,p,m;return U(this,(function(g){switch(g.label){case 0:if(!(n=this._queueMap.get(e.url)))return[3,21];if(n.isResolving)return[3,20];n.isResolving=!0,s=[],a=!0,g.label=1;case 1:g.trys.push([1,15,16,17]),i=f(n.messageQueue),r=i.next(),g.label=2;case 2:if(r.done)return[3,14];switch(l=r.value,l.state){case De.PENDING:case De.UPLOADING:return[3,3];case De.UPLOADED:return[3,4];case De.FAILED:return[3,12]}return[3,13];case 3:return a=!1,s.push(l),[3,13];case 4:if(!a)return[3,10];g.label=5;case 5:return g.trys.push([5,8,,9]),l.state=De.SENDING,[4,this._sendFileMessage(e,l)];case 6:return u=g.sent(),l.deferred.resolve(u),[4,z(100)];case 7:return g.sent(),[3,9];case 8:return o=g.sent(),l.deferred.reject(o),[3,9];case 9:return[3,11];case 10:s.push(l),g.label=11;case 11:return[3,13];case 12:return d=null!==(t=l.error)&&void 0!==t?t:w.unknown,l.deferred.reject(d.code===k.REQUEST_CANCELED?w.fileUploadCanceled:d),[3,13];case 13:return r=i.next(),[3,2];case 14:return[3,17];case 15:return c=g.sent(),p={error:c},[3,17];case 16:try{r&&!r.done&&(m=i.return)&&m.call(i)}finally{if(p)throw p.error}return[7];case 17:return h=n.isResolveRequestPending,n.messageQueue=s,n.isResolving=!1,n.isResolveRequestPending=!1,h?[4,this._resolveMessageQueue(e)]:[3,19];case 18:g.sent(),g.label=19;case 19:return[3,21];case 20:n.isResolveRequestPending=!0,g.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===De.PENDING})))?s.multipleFileUploadInfo?(a=s.multipleFileUploadInfo,i=a.uploadIndex,r=a.uploadCount,l=a.requestHandler,d=s.params,u=d.fileInfoList[i],!x(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 ee({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(te),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 r,u,o,d,c,h,p,m,f,g,y,_;return U(this,(function(v){switch(v.label){case 0:return r=t.multipleFileUploadInfo.uploadIndex,u=n.fileInfoList[r],o=new ee({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(te),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=void 0,u.fileUrl=h,u.fileSize=m,u.thumbnailSizes=g,u._uploadedMetaData=l(l({},u._uploadedMetaData),{requireAuth:_,isUploaded:!0}),[2]}}))}))},e.prototype.request=function(e,t,n,s){return 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 Q,l={requestId:t,params:n,state:De.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,a=this._queueMap.get(e.url);if(a){var i=t?[a.messageQueue.find((function(e){return e.requestId===t}))]:p([],m(a.messageQueue),!1);try{for(var r=f(i),l=r.next();!l.done;l=r.next()){var u=l.value;if(u)switch(u.state){case De.PENDING:u.state=De.FAILED,u.error=w.requestCanceled,this._resolveMessageQueue(e);break;case De.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,Ce={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:A.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:G.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},Re=function(e){return c("number",e.prevResultSize)&&c("number",e.nextResultSize)&&c("boolean",e.isInclusive)&&c("boolean",e.reverse)&&c("string",e.messageTypeFilter)&&h(A,e.messageTypeFilter)&&d("string",e.customTypesFilter,!0)&&d("string",e.senderUserIdsFilter,!0)&&h(G,e.replyType)&&c("boolean",e.includeMetaArray)&&c("boolean",e.includeReactions)&&c("boolean",e.includeParentMessageInfo)&&c("boolean",e.includeThreadInfo)&&c("boolean",e.showSubchannelMessagesOnly)},Le={replyType:G.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},Oe=function(e){return h(G,e.replyType)&&c("boolean",e.includeReactions)&&c("boolean",e.includeMetaArray)&&c("boolean",e.includeParentMessageInfo)&&c("boolean",e.includeThreadInfo)},ke=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),ze=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.message=n?Ae(e,l({},n)):null,s}return e(n,t),n}(i),xe=function(n){function a(e){var a=e.channelType,i=e.channelUrl,l=e.timestamp,u=e.token,o=e.prevResultSize,d=e.nextResultSize,c=e.isInclusive,h=e.reverse,p=e.messageTypeFilter,m=e.customTypesFilter,f=e.senderUserIdsFilter,g=e.replyType,y=e.includeMetaArray,_=e.includeReactions,v=e.parentMessageId,I=e.includeThreadInfo,M=e.includeParentMessageInfo,T=e.showSubchannelMessagesOnly,S=e.checkingContinuousMessages,A=n.call(this)||this;return A.method=t.GET,A.path="".concat(P(a),"/").concat(encodeURIComponent(i),"/messages"),A.params=s(r({is_sdk:!0,prev_limit:o,next_limit:d,include:c,reverse:h,message_ts:l,message_id:u,message_type:null!=p?p:null,custom_types:m,sender_ids:f,include_reply_type:g,with_sorted_meta_array:y,include_reactions:_,parent_message_id:v,include_thread_info:I,include_parent_message_info:M,show_subchannel_message_only:T,include_poll_details:!0,checking_continuous_messages:S})),A}return e(a,n),a}(a),Qe=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.messages=n.messages.map((function(t){return Ae(e,t)})),s}return e(n,t),n}(i),Ge=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),Be=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.updatedMessages=n.updated.map((function(t){return Ae(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),je=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(B,"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(a)),i.params={},i}return e(s,n),s}(a),He=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.message=n?Ae(e,l({},n)):null,s}return e(n,t),n}(i),We={},Ke=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 Ne(e,{sdkState:n,dispatcher:s,requestQueue:a,onlineDetector:i,cacheContext:r}),We[e]=this}return e.of=function(e){return We[e]},e.prototype.buildMessageFromSerializedData=function(e){var t=j(e);switch(t.messageType){case _.USER:return new Ie(this._iid,Ie.payloadify(t));case _.FILE:return Te._isMultipleFilesMessageSerializedData(t)?new Te(this._iid,Te.payloadify(t)):new be(this._iid,be.payloadify(t));case _.ADMIN:return new _e(this._iid,_e.payloadify(t))}throw w.invalidParameters},e.prototype.buildUserMessageCreateParamsFromSerializedData=function(e,t){return s(r({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(r({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 l(l({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildScheduledFileMessageCreateParamsFromSerializedData=function(e,t){return l(l({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildSenderFromSerializedData=function(e){var t=j(e);return new ce(this._iid,ce.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 ke(e),[4,this._requestQueue.send(t)];case 1:return n=s.sent(),[2,n.as(ze).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 je(e),[4,this._requestQueue.send(t)];case 1:return n=s.sent(),[2,n.as(He).message]}}))}))},e.prototype.getMessagesByMessageId=function(e,t,n,s,a){return void 0===a&&(a=H.REQUEST_MESSAGE),b(this,void 0,void 0,(function(){var i,r,u;return U(this,(function(o){switch(o.label){case 0:return i=new xe(l(l({channelType:t,channelUrl:e,token:String(n)},Ce),s)),[4,this._requestQueue.send(i)];case 1:return r=o.sent(),u=r.as(Qe).messages,this._dispatcher.dispatch(new W({messages:u,source:a})),[2,u]}}))}))},e.prototype.getMessagesByTimestamp=function(e,t,n,s,a){return void 0===a&&(a=H.REQUEST_MESSAGE),b(this,void 0,void 0,(function(){var i,r,u;return U(this,(function(o){switch(o.label){case 0:return i=new xe(l(l({channelType:t,channelUrl:e,timestamp:n},Ce),s)),[4,this._requestQueue.send(i)];case 1:return r=o.sent(),u=r.as(Qe).messages,this._dispatcher.dispatch(new W({messages:u,source:a})),[2,u]}}))}))},e.prototype._getMessagesByTimestampForCollection=function(e,t,n,s,a,i){return void 0===a&&(a=H.REQUEST_MESSAGE),b(this,void 0,void 0,(function(){var r,u,o,d;return U(this,(function(c){switch(c.label){case 0:return r=new xe(l(l(l({channelType:t,channelUrl:e,timestamp:n},Ce),s),{checkingContinuousMessages:i})),[4,this._requestQueue.send(r)];case 1:return u=c.sent(),o=u.payload,d=u.as(Qe).messages,this._dispatcher.dispatch(new W({messages:d,source:a})),[2,{messages:d,isContinuousMessages:o}]}}))}))},e.prototype.getThreadedMessagesByTimestamp=function(e,t,n,s){return void 0===s&&(s=H.REQUEST_THREADED_MESSAGE),b(this,void 0,void 0,(function(){var a,i,r,u;return U(this,(function(o){switch(o.label){case 0:return a=new xe(l(l(l({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:t},ge),n),{replyType:G.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),[4,this._requestQueue.send(a)];case 1:return i=o.sent(),r=i.as(Qe).messages,(u=r.slice(1)).forEach((function(t){t.parentMessage=e})),this._dispatcher.dispatch(new W({messages:u,source:s})),[2,{parentMessage:r[0],threadedMessages:u}]}}))}))},e.prototype.getMessageChangelogs=function(e,t,n,a,i){return void 0===i&&(i=H.REQUEST_MESSAGE_CHANGELOGS),b(this,void 0,void 0,(function(){var u,o,d,c,h,p,m,f;return U(this,(function(g){switch(g.label){case 0:return u=new Ge(s(r(l(l({channelType:t,channelUrl:e,timestamp:"number"==typeof n?n:null,token:"string"==typeof n?n:null},Le),a)))),[4,this._requestQueue.send(u)];case 1:return o=g.sent(),d=o.as(Be),c=d.updatedMessages,h=d.deletedMessagesInfo,p=d.hasMore,m=d.nextToken,f=h.map((function(e){return e.messageId})),c.length>0&&this._dispatcher.dispatch(new W({messages:c,source:i})),f.length>0&&this._dispatcher.dispatch(new K({messageIds:f,source:i})),[2,{updatedMessages:c,deletedMessageIds:f,hasMore:p,token:m}]}}))}))},e}(),Ve=function(){function e(){this._onPending=V,this._onFailed=V,this._onSucceeded=V}return e.prototype._trigger=function(e,t){switch(null==t?void 0: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}(),Xe=function(t){function n(e,n){var s=t.call(this,e)||this;s.targetMessageId=0;var a=n.thread_info,i=n.parent_message_id,r=n.channel_url,l=n.channel_type;return a&&c("object",a)&&c("number",i)&&c("string",r)&&c("string",l)&&(s.threadInfo=new ne(e,a),s.targetMessageId=i,s.channelUrl=r,s.channelType=l),s}return e(n,t),n}(o),$e={channelUrl:"",channelType:I.BASE,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(X,"/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),Ye=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.messages=n.results.map((function(t){return Ae(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 Ze=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)&&c("string",this.keyword)&&this.keyword.length>0&&c("boolean",this.reverse)&&c("boolean",this.exactMatch)&&c("string",this.channelUrl)&&c("string",this.channelCustomType)&&(c("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(c("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&h(Pe,this.order)&&c("boolean",this.advancedQuery)&&d("string",this.targetFields,!0)},n.prototype.next=function(){return b(this,void 0,void 0,(function(){var e,t,n,s,a,i,u,o;return U(this,(function(d){switch(d.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=q.of(this._iid).requestQueue,t=new Je(r(l(l({},this),{nextToken:this._nextToken?this._nextToken:null}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=d.sent(),s=n.as(Ye),a=s.messages,i=s.hasNext,u=s.nextToken,o=s.totalCount,this._nextToken=u,this._hasNext=i,this._isLoading=!1,this.totalCount=o,[2,a];case 2:return[2,[]];case 3:throw w.queryInProgress;case 4:return[3,6];case 5:throw w.invalidParameters;case 6:return[2]}}))}))},n}($),et=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=A.ALL,f.customTypesFilter=null,f.senderUserIdsFilter=null,f.replyType=G.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:A.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:G.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)&&c("boolean",this.reverse)&&h(A,this.messageTypeFilter)&&h(G,this.replyType)&&d("string",this.customTypesFilter,!0)&&d("string",this.senderUserIdsFilter,!0)&&c("boolean",this.includeMetaArray)&&c("boolean",this.includeReactions)&&c("boolean",this.includeParentMessageInfo)&&c("boolean",this.includeThreadInfo)&&c("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,Ke.of(this._iid).getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,r({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,p([Number.MAX_SAFE_INTEGER],m(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 w.queryInProgress;case 4:return[3,6];case 5:throw w.invalidParameters;case 6:return[2]}}))}))},n}(J),tt={channelUrl:"",scheduledMessageId:0},nt=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e._onFileUploaded=V,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}(Ve),st=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 Ke(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=l(l({},$e),e),E(function(e){return c("string",e.channelUrl)&&h(I,e.channelType)&&c("number",e.messageId)&&c("boolean",e.includeReactions,!0)&&c("boolean",e.includeMetaArray,!0)&&c("boolean",e.includeParentMessageInfo,!0)&&c("boolean",e.includeThreadInfo,!0)}(t)).throw(w.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=l(l({},tt),e),E(function(e){return c("string",e.channelUrl)&&""!==e.channelUrl&&c("number",e.scheduledMessageId)&&e.scheduledMessageId>0}(t)).throw(w.invalidParameters),[2,this._manager.getScheduledMessage(t)]}))}))},n}(Y);export{de as A,pe as B,be as F,ae as I,st as M,ue as O,ve as P,ie as R,me as S,fe as T,Ie as U,Ze as a,Te as b,Ke as c,le as d,et as e,ce as f,nt as g,Ve as h,Ce as i,Le as j,Oe as k,se as l,we as m,Se as n,te as o,Ae as p,ee as q,_e as r,Xe as s,Pe as t,oe as u,Re as v,re as w,Z as x,ne as y,Me as z}; +import{_ as e,A as t,$ as n,e as s,f as a,h as i,u as r,g as l,U as u,a0 as o,m as d,a as c,M as h,r as p,s as m,K as f,X as g,a1 as y,a2 as _,a3 as v,Q as I,a4 as M,a5 as T,a6 as S,a7 as A,b,c as U,t as E,S as w,a8 as F,V as q,a9 as D,aa as N,ab as P,ac as C,W as R,x as L,y as O,ad as k,ae as z,i as x,af as Q,ag as G,ah as B,w as j,ai as H,aj as W,ak as K,n as V,al as X,B as $,am as J,an as Y}from"./__bundle-087816c3.js";var Z,ee=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&&c("number",r)&&(this.key=a,this.userIds=i,this.updatedAt=r);var l={};try{for(var u=f(this.userIds),o=u.next();!o.done;o=u.next()){l[o.value]=this.updatedAt}}catch(e){t={error:e}}finally{try{o&&!o.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 s(r({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}))},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 Z.ADD:t<0&&this.userIds.push(e.userId);break;case Z.DELETE:t>=0&&this.userIds.splice(t,1)}this._version[e.userId]=e.updatedAt}this.updatedAt=Math.max(this.updatedAt,e.updatedAt)}},e}(),le=function(){function e(e){this.key=e.key,this.value=d("string",e.value)?p([],m(e.value),!1):[]}return e.payloadify=function(e){var t;return s(r({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}))},e}(),ue=function(){function e(e){this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,this.url=e.url,e.secure_url&&(this.secureUrl=e.secure_url),e.type&&(this.type=e.type),e.width&&(this.width=e.width),e.height&&(this.height=e.height),e.alt&&(this.alt=e.alt)}return e.payloadify=function(e){var t,n;return s(r({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}))},e}(),oe=function(){function e(e){this.title=null,this.url=null,this.description=null,this.defaultImage=null,e["og:title"]&&(this.title=e["og:title"]),e["og:url"]&&(this.url=e["og:url"]),e["og:description"]&&(this.description=e["og:description"]),e["og:image"]&&(this.defaultImage=new ue(e["og:image"]))}return e.payloadify=function(e){return s(r({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?ue.payloadify(e.defaultImage):null}))},e}(),de=function(){function e(e){var t,n;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 s(r({name:e.name,volume:e.volume}))},e}(),ce=function(t){function n(e,n){var s,a=this;return(a=t.call(this,e,n)||this).isBlockedByMe=!1,a.role=h(g,n.role)?n.role:g.NONE,a.isBlockedByMe=null!==(s=n.is_blocked_by_me)&&void 0!==s&&s,a}return e(n,t),n.payloadify=function(e){return s(r(l(l({},t.payloadify.call(this,e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})))},n}(u);!function(e){e.PENDING="pending",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled"}(se||(se={})),function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(ae||(ae={}));var he=function(e){switch(e){case _.BASE:return"";case _.USER:return"MESG";case _.FILE:return"FILE";case _.ADMIN:return"ADMM"}},pe=function(t){function n(e,n){var s,a,i,r,l,o,d,c,p,m,f,g,y,v,T,S,A=this;(A=t.call(this,e)||this).channelType=I.BASE,A.parentMessage=null,A.silent=!1,A.isOperatorMessage=!1,A.messageType=_.BASE,A.mentionType=null,A.threadInfo=null,A.reactions=[],A.metaArrays=[],A.appleCriticalAlertOptions=null,A.createdAt=0,A.updatedAt=0,A.scheduledInfo=null,A.extendedMessage={},A._isContinuousMessages=!1,A._scheduledStatus=null,A.messageId=null!==(a=null!==(s=n.msg_id)&&void 0!==s?s:n.message_id)&&void 0!==a?a:0,A.channelUrl=n.channel_url,A.channelType=h(I,n.channel_type)?n.channel_type:I.GROUP,n.channel&&(n.channel.channel_url&&(A.channelUrl=n.channel.channel_url),n.channel.channel_type&&(A.channelType=n.channel.channel_type)),A.parentMessageId=null!==(i="string"==typeof n.parent_message_id?parseInt(n.parent_message_id):n.parent_message_id)&&void 0!==i?i:0,A.data=null!==(r=n.data)&&void 0!==r?r:"",A.customType=null!==(l=n.custom_type)&&void 0!==l?l:"",A.mentionType=h(M,n.mention_type)?n.mention_type:null,A.mentionedUsers=n.mentioned_users?n.mentioned_users.map((function(e){return new u(A._iid,e)})):null,A.mentionedUserIds=null!==(o=n.mentioned_user_ids)&&void 0!==o?o:null,A.mentionedUsers&&!A.mentionedUserIds&&(A.mentionedUserIds=A.mentionedUsers.map((function(e){return e.userId}))),A.mentionedMessageTemplate=null!==(d=n.mentioned_message_template)&&void 0!==d?d:"",A.threadInfo=n.thread_info?new ne(A._iid,n.thread_info):null,A.reactions=n.reactions?n.reactions.map((function(e){return new re(e)})):[];var b=null!==(c=n.metaarray)&&void 0!==c?c:{},U=null!==(p=n.metaarray_key_order)&&void 0!==p?p:Object.keys(b).sort((function(e,t){return e.localeCompare(t)}));A.metaArrays=[];for(var E=0;E=t)return this.parentMessage=e,!0}return!1},n}(o),me=function(t){function n(e,n){var s,a,i,r,l=this;if((l=t.call(this,e,n)||this).reqId="",l.replyToChannel=!1,l.errorCode=0,l.sender=n.user?new ce(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&&h(T,n.request_state)&&(l.sendingStatus=n.request_state),!l.sendingStatus)if(l.messageId>0)l.sendingStatus=T.SUCCEEDED;else if(l.scheduledInfo)switch(n.scheduled_status&&(l._scheduledStatus=n.scheduled_status),n.scheduled_status){case ae.SENT:case ae.IN_QUEUE:l.sendingStatus=T.SUCCEEDED;break;case ae.PENDING:l.sendingStatus=T.SCHEDULED;break;case ae.FAILED:case ae.REMOVED:l.sendingStatus=T.FAILED;break;case ae.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 s(r(l(l({},t.payloadify.call(this,e)),{user:ce.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode})))},Object.defineProperty(n.prototype,"isResendable",{get:function(){return this.sendingStatus===T.FAILED&&S(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}(pe),fe=function(){function e(e){var t,n;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 s(r({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}))},Object.defineProperty(e.prototype,"plainUrl",{get:function(){return this.url.split("?auth=")[0]},enumerable:!1,configurable:!0}),e}(),ge={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:A.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},ye=function(e){return c("number",e.prevResultSize)&&c("number",e.nextResultSize)&&c("boolean",e.isInclusive)&&c("boolean",e.reverse)&&c("string",e.messageTypeFilter)&&h(A,e.messageTypeFilter)&&d("string",e.customTypesFilter,!0)&&d("string",e.senderUserIdsFilter,!0)&&c("boolean",e.includeMetaArray)&&c("boolean",e.includeReactions)&&c("boolean",e.includeParentMessageInfo)},_e=function(t){function n(e,n){var a,i,u,o,d=this;if((d=t.call(this,e,n)||this).translations={},d.message=null!==(a=n.message)&&void 0!==a?a:"",d.messageType=_.ADMIN,d.translations=null!==(i=n.translations)&&void 0!==i?i:{},n.parent_message_info){var c=n.parent_message_info;d.parentMessage=Ae(e,s(r(l(l({},c),{message_id:d.parentMessageId,channel_url:d.channelUrl,channel_type:d.channelType,file:c.file,url:null===(u=c.file)||void 0===u?void 0:u.url,require_auth:null===(o=c.file)||void 0===o?void 0:o.require_auth}))))}return d}return e(n,t),n.payloadify=function(e){return s(r(l(l({},t.payloadify.call(this,e)),{message:e.message,translations:e.translations,parent_message_info:e.parentMessage?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=l(l({},ge),t),E(this.messageId>0&&c("number",e)&&ye(n)).throw(w.invalidParameters),[4,Ke.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,s.sent()]}}))}))},n}(pe),ve=function(){function e(e){var t,n;this.detail={},this.type=null!==(t=e.type)&&void 0!==t?t:"",this.vendor=null!==(n=e.vendor)&&void 0!==n?n:"",e.detail&&c("object",e.detail)&&!Array.isArray(e.detail)&&(this.detail=e.detail)}return e.payloadify=function(e){return s(r({type:e.type,vendor:e.vendor,detail:e.detail}))},e}(),Ie=function(t){function n(e,n){var a,i,u,o,d,c,h,p=this;if((p=t.call(this,e,n)||this).message="",p.messageParams=null,p.translations={},p.translationTargetLanguages=[],p.messageSurvivalSeconds=-1,p.plugins=[],p._poll=null,p.message=n.message,p.messageType=_.USER,p.translations=null!==(u=n.translations)&&void 0!==u?u:{},p.translationTargetLanguages=null!==(o=n.target_langs)&&void 0!==o?o:[],0===Object.keys(p.translations).length&&p.translationTargetLanguages.length>0)try{for(var m=f(p.translationTargetLanguages),g=m.next();!g.done;g=m.next()){var y=g.value;p.translations[y]=""}}catch(e){a={error:e}}finally{try{g&&!g.done&&(i=m.return)&&i.call(m)}finally{if(a)throw a.error}}if(p.messageSurvivalSeconds=null!==(d=n.message_survival_seconds)&&void 0!==d?d:-1,p.plugins=n.plugins?n.plugins.map((function(e){return new ve(e)})):[],p._poll=n.poll?new F(p._iid,n.poll):null,n.parent_message_info){var v=n.parent_message_info;p.parentMessage=Ae(e,s(r(l(l({},v),{created_at:v.ts,message_id:p.parentMessageId,channel_url:p.channelUrl,channel_type:p.channelType,file:v.file,url:null===(c=v.file)||void 0===c?void 0:c.url,require_auth:null===(h=v.file)||void 0===h?void 0:h.require_auth}))))}return p}return e(n,t),n.payloadify=function(e){return s(r(l(l({},t.payloadify.call(this,e)),{message:e.message,translations:e.translations,message_survival_seconds:e.messageSurvivalSeconds,plugins:e.plugins.map((function(e){return ve.payloadify(e)})),poll:e._poll?F.payloadify(e._poll):null,parent_message_info:e.parentMessage?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=l(l({},ge),t),E(this.messageId>0&&c("number",e)&&ye(n)).throw(w.invalidParameters),[4,Ke.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}(me),Me=function(t){function n(e,n){var s,a,i,r,u,o=this;(o=t.call(this,e)||this).plainUrl="",o.fileName=null,o.mimeType=null,o.fileSize=0,o.thumbnails=[],o._requireAuth=!1,o.plainUrl=null!==(s=n.url)&&void 0!==s?s:"",o.fileName=null!==(a=n.file_name)&&void 0!==a?a:null,o.mimeType=null!==(i=n.file_type)&&void 0!==i?i:null,o.fileSize=null!==(r=n.file_size)&&void 0!==r?r:0,o._requireAuth=null!==(u=n.require_auth)&&void 0!==u&&u;var d=q.of(o._iid).sessionManager;return o.thumbnails=n.thumbnails?n.thumbnails.map((function(e){return new fe(l(l({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(o._requireAuth?"?auth=".concat(d.ekey):"")}))})):[],o}return e(n,t),n.payloadify=function(e){var t;return s(r({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=q.of(this._iid).sessionManager;return this._requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl},enumerable:!1,configurable:!0}),n}(o),Te=function(t){function n(e,n){var a,i,u,o,d,c=this;if((c=t.call(this,e,n)||this).messageParams=null,c.fileInfoList=[],c.messageSurvivalSeconds=-1,c.messageType=_.FILE,c.fileInfoList=null!==(i=null===(a=n.files)||void 0===a?void 0:a.map((function(t){return new Me(e,t)})))&&void 0!==i?i:[],c.messageSurvivalSeconds=null!==(u=n.message_survival_seconds)&&void 0!==u?u:-1,n.parent_message_info){var h=n.parent_message_info;c.parentMessage=Ae(e,s(r(l(l({},h),{created_at:h.ts,message_id:c.parentMessageId,channel_url:c.channelUrl,channel_type:c.channelType,file:h.file,url:null===(o=h.file)||void 0===o?void 0:o.url,require_auth:null===(d=h.file)||void 0===d?void 0:d.require_auth}))))}return c}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=l(l({},ge),t),E(this.messageId>0&&c("number",e)&&ye(n)).throw(w.invalidParameters),[4,Ke.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,s.sent()]}}))}))},n.payloadify=function(e){return s(r(l(l({},t.payloadify.call(this,e)),{files:e.fileInfoList&&e.fileInfoList&&Array.isArray(e.fileInfoList)?e.fileInfoList.map((function(e){return Me.payloadify(e)})):null,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?t._getParentMessageInfoPayload.call(this,e.parentMessage):null})))},n._isMultipleFilesMessagePayload=function(e){var t=e.files;return Array.isArray(t)&&t.length>=2},n._isMultipleFilesMessageSerializedData=function(e){var t=e.fileInfoList;return Array.isArray(t)},n}(me),Se=function(e){switch(e.messageType){case _.USER:return Ie.payloadify(e);case _.FILE:return e.fileInfoList?Te.payloadify(e):be.payloadify(e);case _.ADMIN:return _e.payloadify(e);default:throw w.unknown}},Ae=function(e,t){switch(t.type){case"MESG":return new Ie(e,t);case"FILE":return Te._isMultipleFilesMessagePayload(t)?new Te(e,t):new be(e,t);case"ADMM":case"BRDM":return new _e(e,t)}throw w.unknown},be=function(t){function n(e,n){var a,i,u,o,d,c,h,p,m,f,g,y,v,I,M=this;(M=t.call(this,e,n)||this).messageParams=null,M.plainUrl="",M.requireAuth=!1,M.thumbnails=[],M.messageSurvivalSeconds=-1,M.messageType=_.FILE;var T=n.file;M.plainUrl=(null!==(i=null!==(a=null==T?void 0:T.url)&&void 0!==a?a:n.url)&&void 0!==i?i:"").split("?auth=")[0],M.name=null!==(o=null!==(u=null==T?void 0:T.name)&&void 0!==u?u:n.name)&&void 0!==o?o:"File",M.size=null!==(c=null!==(d=null==T?void 0:T.size)&&void 0!==d?d:n.size)&&void 0!==c?c:0,M.data=null!==(p=null!==(h=null==T?void 0:T.data)&&void 0!==h?h:n.custom)&&void 0!==p?p:"",M.type=T?null!==(m=T.type)&&void 0!==m?m:"":null!==(f=n.type)&&void 0!==f?f:"";var S=q.of(M._iid).sessionManager;if(M.requireAuth=null!==(g=n.require_auth)&&void 0!==g&&g,M.thumbnails=n.thumbnails?n.thumbnails.map((function(e){return new fe(l(l({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(M.requireAuth?"?auth=".concat(S.ekey):"")}))})):[],M.messageSurvivalSeconds=null!==(y=n.message_survival_seconds)&&void 0!==y?y:-1,n.parent_message_info){var A=n.parent_message_info;M.parentMessage=Ae(e,s(r(l(l({},A),{created_at:A.ts,message_id:M.parentMessageId,channel_url:M.channelUrl,channel_type:M.channelType,file:A.file,url:null===(v=A.file)||void 0===v?void 0:v.url,require_auth:null===(I=A.file)||void 0===I?void 0:I.require_auth}))))}return M}return e(n,t),n.payloadify=function(e){var n;return s(r(l(l({},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:e.parentMessage?t._getParentMessageInfoPayload.call(this,e.parentMessage):null})))},Object.defineProperty(n.prototype,"url",{get:function(){var e=q.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=l(l({},ge),t),E(this.messageId>0&&c("number",e)&&ye(n)).throw(w.invalidParameters),[4,Ke.of(this._iid).getThreadedMessagesByTimestamp(this,e,n)];case 1:return[2,s.sent()]}}))}))},n}(me),Ue=function(t){function n(e){var n,a,i,l=[];return e.mentionType===M.USERS&&(e.mentionedUserIds?l=e.mentionedUserIds:e.mentionedUsers&&(l=e.mentionedUsers.map((function(e){return e.userId})))),t.call(this,{code:"FILE",ackRequired:!0,payload:s(r({channel_url:e.channelUrl,files:e.files?qe(e.files):null,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:l,push_option:e.pushNotificationDeliveryOption&&e.pushNotificationDeliveryOption!==D.DEFAULT?e.pushNotificationDeliveryOption:void 0,apple_critical_alert_options:e.appleCriticalAlertOptions?de.payloadify(e.appleCriticalAlertOptions):null,silent:e.silent,reply_to_channel:e.isReplyToChannel,parent_message_id:e.parentMessageId?e.parentMessageId:null,req_id:e.reqId,pin_message:e.isPinnedMessage}))})||this}return e(n,t),n}(N),Ee=function(n){function a(e){var a,i,l=this;l=n.call(this)||this;var u=[];return e.mentionType===M.USERS&&(e.mentionedUserIds?u=e.mentionedUserIds:e.mentionedUsers&&(u=e.mentionedUsers.map((function(e){return e.userId})))),l.method=t.POST,l.path="".concat(P(e.channelType),"/").concat(encodeURIComponent(e.channelUrl),"/messages"),l.params=s(r({message_type:_.FILE,user_id:e.userId,files:e.files?qe(e.files):null,url:e.fileUrl,mention_type:e.mentionType,mentioned_user_ids:u,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 fe.payloadify(e)})),require_auth:e.requireAuth,sorted_metaarray:null===(i=e.metaArrays)||void 0===i?void 0:i.map((function(e){return le.payloadify(e)})),push_option:e.pushNotificationDeliveryOption,parent_message_id:e.parentMessageId?e.parentMessageId:null,apple_critical_alert_options:e.appleCriticalAlertOptions?de.payloadify(e.appleCriticalAlertOptions):null,reply_to_channel:e.isReplyToChannel,req_id:e.reqId,pin_message:e.isPinnedMessage})),l}return e(a,n),a}(a),we=function(t){function n(e,n,s){var a,i,r,l,u=this;(u=t.call(this,e,"FILE",s)||this).message=s.files&&s.files.length>=2?new Te(e,s):new be(e,s);var o=q.of(e).sdkState;return u.isMentioned=C(u.message.mentionType,null!==(r=null!==(a=u.message.mentionedUserIds)&&void 0!==a?a:null===(i=u.message.mentionedUsers)||void 0===i?void 0:i.map((function(e){return e.userId})))&&void 0!==r?r:[],o.userId),u.forceUpdateLastMessage=null!==(l=s.force_update_last_message)&&void 0!==l&&l,u}return e(n,t),n}(R),Fe=function(t){function n(e,n){var s,a,i,r,l=this;(l=t.call(this,e,n)||this).message=n.files&&n.files.length>=2?new Te(e,n):new be(e,n);var u=q.of(e).sdkState;return l.isMentioned=C(l.message.mentionType,null!==(i=null!==(s=l.message.mentionedUserIds)&&void 0!==s?s:null===(a=l.message.mentionedUsers)||void 0===a?void 0:a.map((function(e){return e.userId})))&&void 0!==i?i:[],u.userId),l.forceUpdateLastMessage=null!==(r=n.force_update_last_message)&&void 0!==r&&r,l}return e(n,t),n}(i);function qe(e){return e.map((function(e){var t,n;return s(r({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 fe.payloadify(e)})),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth}))}))}var De;!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"}(De||(De={}));var Ne=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._iid=e,this._sdkState=n,this._requestQueue=a,this._cacheContext=r,this._dispatcher=s,this._dispatcher.on((function(e){e instanceof L&&(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(we).message];case 2:return s=new Ee(l(l({},n),{userId:this._sdkState.userId})),[4,this._requestQueue.send(s)];case 3:return a=i.sent(),[2,a.as(Fe).message]}}))}))},e.prototype._createSendFileMessageRequestParams=function(e,t){var n=l(l({},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){var t;return b(this,void 0,void 0,(function(){var n,s,a,i,r,l,u,o,d,c,h,p,m;return U(this,(function(g){switch(g.label){case 0:if(!(n=this._queueMap.get(e.url)))return[3,21];if(n.isResolving)return[3,20];n.isResolving=!0,s=[],a=!0,g.label=1;case 1:g.trys.push([1,15,16,17]),i=f(n.messageQueue),r=i.next(),g.label=2;case 2:if(r.done)return[3,14];switch(l=r.value,l.state){case De.PENDING:case De.UPLOADING:return[3,3];case De.UPLOADED:return[3,4];case De.FAILED:return[3,12]}return[3,13];case 3:return a=!1,s.push(l),[3,13];case 4:if(!a)return[3,10];g.label=5;case 5:return g.trys.push([5,8,,9]),l.state=De.SENDING,[4,this._sendFileMessage(e,l)];case 6:return u=g.sent(),l.deferred.resolve(u),[4,z(100)];case 7:return g.sent(),[3,9];case 8:return o=g.sent(),l.deferred.reject(o),[3,9];case 9:return[3,11];case 10:s.push(l),g.label=11;case 11:return[3,13];case 12:return d=null!==(t=l.error)&&void 0!==t?t:w.unknown,l.deferred.reject(d.code===k.REQUEST_CANCELED?w.fileUploadCanceled:d),[3,13];case 13:return r=i.next(),[3,2];case 14:return[3,17];case 15:return c=g.sent(),p={error:c},[3,17];case 16:try{r&&!r.done&&(m=i.return)&&m.call(i)}finally{if(p)throw p.error}return[7];case 17:return h=n.isResolveRequestPending,n.messageQueue=s,n.isResolving=!1,n.isResolveRequestPending=!1,h?[4,this._resolveMessageQueue(e)]:[3,19];case 18:g.sent(),g.label=19;case 19:return[3,21];case 20:n.isResolveRequestPending=!0,g.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===De.PENDING})))?s.multipleFileUploadInfo?(a=s.multipleFileUploadInfo,i=a.uploadIndex,r=a.uploadCount,l=a.requestHandler,d=s.params,u=d.fileInfoList[i],!x(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 ee({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(te),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 r,u,o,d,c,h,p,m,f,g,y,_;return U(this,(function(v){switch(v.label){case 0:return r=t.multipleFileUploadInfo.uploadIndex,u=n.fileInfoList[r],o=new ee({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(te),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=void 0,u.fileUrl=h,u.fileSize=m,u.thumbnailSizes=g,u._uploadedMetaData=l(l({},u._uploadedMetaData),{requireAuth:_,isUploaded:!0}),[2]}}))}))},e.prototype.request=function(e,t,n,s){return 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 Q,l={requestId:t,params:n,state:De.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,a=this._queueMap.get(e.url);if(a){var i=t?[a.messageQueue.find((function(e){return e.requestId===t}))]:p([],m(a.messageQueue),!1);try{for(var r=f(i),l=r.next();!l.done;l=r.next()){var u=l.value;if(u)switch(u.state){case De.PENDING:u.state=De.FAILED,u.error=w.requestCanceled,this._resolveMessageQueue(e);break;case De.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,Ce={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:A.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:G.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},Re=function(e){return c("number",e.prevResultSize)&&c("number",e.nextResultSize)&&c("boolean",e.isInclusive)&&c("boolean",e.reverse)&&c("string",e.messageTypeFilter)&&h(A,e.messageTypeFilter)&&d("string",e.customTypesFilter,!0)&&d("string",e.senderUserIdsFilter,!0)&&h(G,e.replyType)&&c("boolean",e.includeMetaArray)&&c("boolean",e.includeReactions)&&c("boolean",e.includeParentMessageInfo)&&c("boolean",e.includeThreadInfo)&&c("boolean",e.showSubchannelMessagesOnly)},Le={replyType:G.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},Oe=function(e){return h(G,e.replyType)&&c("boolean",e.includeReactions)&&c("boolean",e.includeMetaArray)&&c("boolean",e.includeParentMessageInfo)&&c("boolean",e.includeThreadInfo)},ke=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),ze=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.message=n?Ae(e,l({},n)):null,s}return e(n,t),n}(i),xe=function(n){function a(e){var a=e.channelType,i=e.channelUrl,l=e.timestamp,u=e.token,o=e.prevResultSize,d=e.nextResultSize,c=e.isInclusive,h=e.reverse,p=e.messageTypeFilter,m=e.customTypesFilter,f=e.senderUserIdsFilter,g=e.replyType,y=e.includeMetaArray,_=e.includeReactions,v=e.parentMessageId,I=e.includeThreadInfo,M=e.includeParentMessageInfo,T=e.showSubchannelMessagesOnly,S=e.checkingContinuousMessages,A=n.call(this)||this;return A.method=t.GET,A.path="".concat(P(a),"/").concat(encodeURIComponent(i),"/messages"),A.params=s(r({is_sdk:!0,prev_limit:o,next_limit:d,include:c,reverse:h,message_ts:l,message_id:u,message_type:null!=p?p:null,custom_types:m,sender_ids:f,include_reply_type:g,with_sorted_meta_array:y,include_reactions:_,parent_message_id:v,include_thread_info:I,include_parent_message_info:M,show_subchannel_message_only:T,include_poll_details:!0,checking_continuous_messages:S})),A}return e(a,n),a}(a),Qe=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.messages=n.messages.map((function(t){return Ae(e,t)})),s}return e(n,t),n}(i),Ge=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),Be=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.updatedMessages=n.updated.map((function(t){return Ae(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),je=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(B,"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(a)),i.params={},i}return e(s,n),s}(a),He=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.message=n?Ae(e,l({},n)):null,s}return e(n,t),n}(i),We={},Ke=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 Ne(e,{sdkState:n,dispatcher:s,requestQueue:a,onlineDetector:i,cacheContext:r}),We[e]=this}return e.of=function(e){return We[e]},e.prototype.buildMessageFromSerializedData=function(e){var t=j(e);switch(t.messageType){case _.USER:return new Ie(this._iid,Ie.payloadify(t));case _.FILE:return Te._isMultipleFilesMessageSerializedData(t)?new Te(this._iid,Te.payloadify(t)):new be(this._iid,be.payloadify(t));case _.ADMIN:return new _e(this._iid,_e.payloadify(t))}throw w.invalidParameters},e.prototype.buildUserMessageCreateParamsFromSerializedData=function(e,t){return s(r({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(r({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 l(l({},this.buildUserMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildScheduledFileMessageCreateParamsFromSerializedData=function(e,t){return l(l({},this.buildFileMessageCreateParamsFromSerializedData(e,t)),{scheduledAt:e.scheduledAt})},e.prototype.buildSenderFromSerializedData=function(e){var t=j(e);return new ce(this._iid,ce.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 ke(e),[4,this._requestQueue.send(t)];case 1:return n=s.sent(),[2,n.as(ze).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 je(e),[4,this._requestQueue.send(t)];case 1:return n=s.sent(),[2,n.as(He).message]}}))}))},e.prototype.getMessagesByMessageId=function(e,t,n,s,a){return void 0===a&&(a=H.REQUEST_MESSAGE),b(this,void 0,void 0,(function(){var i,r,u;return U(this,(function(o){switch(o.label){case 0:return i=new xe(l(l({channelType:t,channelUrl:e,token:String(n)},Ce),s)),[4,this._requestQueue.send(i)];case 1:return r=o.sent(),u=r.as(Qe).messages,this._dispatcher.dispatch(new W({messages:u,source:a})),[2,u]}}))}))},e.prototype.getMessagesByTimestamp=function(e,t,n,s,a){return void 0===a&&(a=H.REQUEST_MESSAGE),b(this,void 0,void 0,(function(){var i,r,u;return U(this,(function(o){switch(o.label){case 0:return i=new xe(l(l({channelType:t,channelUrl:e,timestamp:n},Ce),s)),[4,this._requestQueue.send(i)];case 1:return r=o.sent(),u=r.as(Qe).messages,this._dispatcher.dispatch(new W({messages:u,source:a})),[2,u]}}))}))},e.prototype._getMessagesByTimestampForCollection=function(e,t,n,s,a,i){return void 0===a&&(a=H.REQUEST_MESSAGE),b(this,void 0,void 0,(function(){var r,u,o,d;return U(this,(function(c){switch(c.label){case 0:return r=new xe(l(l(l({channelType:t,channelUrl:e,timestamp:n},Ce),s),{checkingContinuousMessages:i})),[4,this._requestQueue.send(r)];case 1:return u=c.sent(),o=u.payload,d=u.as(Qe).messages,this._dispatcher.dispatch(new W({messages:d,source:a})),[2,{messages:d,isContinuousMessages:o}]}}))}))},e.prototype.getThreadedMessagesByTimestamp=function(e,t,n,s){return void 0===s&&(s=H.REQUEST_THREADED_MESSAGE),b(this,void 0,void 0,(function(){var a,i,r,u;return U(this,(function(o){switch(o.label){case 0:return a=new xe(l(l(l({channelUrl:e.channelUrl,channelType:e.channelType,timestamp:t},ge),n),{replyType:G.ALL,parentMessageId:e.messageId,includeThreadInfo:!0})),[4,this._requestQueue.send(a)];case 1:return i=o.sent(),r=i.as(Qe).messages,(u=r.slice(1)).forEach((function(t){t.parentMessage=e})),this._dispatcher.dispatch(new W({messages:u,source:s})),[2,{parentMessage:r[0],threadedMessages:u}]}}))}))},e.prototype.getMessageChangelogs=function(e,t,n,a,i){return void 0===i&&(i=H.REQUEST_MESSAGE_CHANGELOGS),b(this,void 0,void 0,(function(){var u,o,d,c,h,p,m,f;return U(this,(function(g){switch(g.label){case 0:return u=new Ge(s(r(l(l({channelType:t,channelUrl:e,timestamp:"number"==typeof n?n:null,token:"string"==typeof n?n:null},Le),a)))),[4,this._requestQueue.send(u)];case 1:return o=g.sent(),d=o.as(Be),c=d.updatedMessages,h=d.deletedMessagesInfo,p=d.hasMore,m=d.nextToken,f=h.map((function(e){return e.messageId})),c.length>0&&this._dispatcher.dispatch(new W({messages:c,source:i})),f.length>0&&this._dispatcher.dispatch(new K({messageIds:f,source:i})),[2,{updatedMessages:c,deletedMessageIds:f,hasMore:p,token:m}]}}))}))},e}(),Ve=function(){function e(){this._onPending=V,this._onFailed=V,this._onSucceeded=V}return e.prototype._trigger=function(e){switch(null==e?void 0:e.sendingStatus){case T.PENDING:0===e.errorCode&&this._onPending(e);break;case T.SCHEDULED:case T.SUCCEEDED:this._onSucceeded(e)}},e.prototype._triggerFailed=function(e,t){switch(null==t?void 0:t.sendingStatus){case T.FAILED:case T.CANCELED:this._onFailed(e,t.scheduledInfo?null: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}(),Xe=function(t){function n(e,n){var s=t.call(this,e)||this;s.targetMessageId=0;var a=n.thread_info,i=n.parent_message_id,r=n.channel_url,l=n.channel_type;return a&&c("object",a)&&c("number",i)&&c("string",r)&&c("string",l)&&(s.threadInfo=new ne(e,a),s.targetMessageId=i,s.channelUrl=r,s.channelType=l),s}return e(n,t),n}(o),$e={channelUrl:"",channelType:I.BASE,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(X,"/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),Ye=function(t){function n(e,n){var s=t.call(this,e,n)||this;return s.messages=n.results.map((function(t){return Ae(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 Ze=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)&&c("string",this.keyword)&&this.keyword.length>0&&c("boolean",this.reverse)&&c("boolean",this.exactMatch)&&c("string",this.channelUrl)&&c("string",this.channelCustomType)&&(c("number",this.messageTimestampFrom)||null===this.messageTimestampFrom)&&(c("number",this.messageTimestampTo)||null===this.messageTimestampTo)&&h(Pe,this.order)&&c("boolean",this.advancedQuery)&&d("string",this.targetFields,!0)},n.prototype.next=function(){return b(this,void 0,void 0,(function(){var e,t,n,s,a,i,u,o;return U(this,(function(d){switch(d.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,e=q.of(this._iid).requestQueue,t=new Je(r(l(l({},this),{nextToken:this._nextToken?this._nextToken:null}))),[4,e.send(t)]):[3,2]:[3,5];case 1:return n=d.sent(),s=n.as(Ye),a=s.messages,i=s.hasNext,u=s.nextToken,o=s.totalCount,this._nextToken=u,this._hasNext=i,this._isLoading=!1,this.totalCount=o,[2,a];case 2:return[2,[]];case 3:throw w.queryInProgress;case 4:return[3,6];case 5:throw w.invalidParameters;case 6:return[2]}}))}))},n}($),et=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=A.ALL,f.customTypesFilter=null,f.senderUserIdsFilter=null,f.replyType=G.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:A.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:G.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)&&c("boolean",this.reverse)&&h(A,this.messageTypeFilter)&&h(G,this.replyType)&&d("string",this.customTypesFilter,!0)&&d("string",this.senderUserIdsFilter,!0)&&c("boolean",this.includeMetaArray)&&c("boolean",this.includeReactions)&&c("boolean",this.includeParentMessageInfo)&&c("boolean",this.includeThreadInfo)&&c("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,Ke.of(this._iid).getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,r({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,p([Number.MAX_SAFE_INTEGER],m(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 w.queryInProgress;case 4:return[3,6];case 5:throw w.invalidParameters;case 6:return[2]}}))}))},n}(J),tt={channelUrl:"",scheduledMessageId:0},nt=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e._onFileUploaded=V,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}(Ve),st=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 Ke(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=l(l({},$e),e),E(function(e){return c("string",e.channelUrl)&&h(I,e.channelType)&&c("number",e.messageId)&&c("boolean",e.includeReactions,!0)&&c("boolean",e.includeMetaArray,!0)&&c("boolean",e.includeParentMessageInfo,!0)&&c("boolean",e.includeThreadInfo,!0)}(t)).throw(w.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=l(l({},tt),e),E(function(e){return c("string",e.channelUrl)&&""!==e.channelUrl&&c("number",e.scheduledMessageId)&&e.scheduledMessageId>0}(t)).throw(w.invalidParameters),[2,this._manager.getScheduledMessage(t)]}))}))},n}(Y);export{de as A,pe as B,be as F,ae as I,st as M,ue as O,ve as P,ie as R,me as S,fe as T,Ie as U,Ze as a,Te as b,Ke as c,le as d,et as e,ce as f,nt as g,Ve as h,Ce as i,Le as j,Oe as k,se as l,we as m,Se as n,te as o,Ae as p,ee as q,_e as r,Xe as s,Pe as t,oe as u,Re as v,re as w,Z as x,ne as y,Me as z}; diff --git a/lib/__bundle-ad161b2c.js b/lib/__bundle-8f39cad4.js similarity index 99% rename from lib/__bundle-ad161b2c.js rename to lib/__bundle-8f39cad4.js index 7d1c139..3429e58 100644 --- a/lib/__bundle-ad161b2c.js +++ b/lib/__bundle-8f39cad4.js @@ -1 +1 @@ -import{_ as t,A as n,au as e,f as o,a8 as s,h as a,ao as i,ab as r,e as l,a as u,av as c,aw as h,Q as p,M as d,w as f,b as _,c as v,ai as m,t as g,S as I,g as w,ax as y,u as U,am as T,V as k,U as b}from"./__bundle-75942676.js";var P=function(o){function s(t){var s=t.title,a=t.optionTexts,i=t.data,r=t.allowUserSuggestion,l=t.allowMultipleVotes,u=t.closeAt,c=o.call(this)||this;return c.method=n.POST,c.path=e,c.params={title:s,options:a,data:i,allow_user_suggestion:r,allow_multiple_votes:l,close_at:u},c}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}(a),O=function(o){function s(t){var s=t.channelUrl,a=t.channelType,i=t.pollId,r=o.call(this)||this;return r.method=n.GET,r.path="".concat(e,"/").concat(encodeURIComponent(i)),r.params={channel_url:s,channel_type:a},r}return t(s,o),s}(o),S=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}(a),q=function(o){function s(t){var s=t.channelUrl,a=t.channelType,i=t.pollId,r=t.pollOptionId,l=o.call(this)||this;return l.method=n.GET,l.path="".concat(e,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(r)),l.params={channel_url:s,channel_type:a},l}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 i(t,e),o}return t(e,n),e}(a),C=function(e){function o(t){var o=t.channelType,s=t.channelUrl,a=t.timestamp,i=t.token,u=e.call(this)||this;return u.method=n.GET,u.path="".concat(r(o),"/").concat(encodeURIComponent(s),"/polls/changelogs"),u.params=l({change_ts:a,token:i}),u}return t(o,e),o}(o),M=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 new s(t,n)}(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}(a),Q={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},E=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)},A={channelUrl:"",channelType:p.BASE,pollId:0,pollOptionId:0},G=function(t){return u("string",t.channelUrl)&&""!==t.channelUrl&&d(p,t.channelType)&&u("number",t.pollId)&&t.pollId>0&&u("number",t.pollOptionId)&&t.pollOptionId>0},N={channelUrl:"",channelType:p.BASE,pollId:0},R=function(t){return u("string",t.channelUrl)&&""!==t.channelUrl&&d(p,t.channelType)&&u("number",t.pollId)},V={},B=function(){function t(t,n){var e=n.sdkState,o=n.dispatcher,s=n.sessionManager,a=n.requestQueue,i=n.logger;this._iid=t,this._sdkState=e,this._sessionManager=s,this._requestQueue=a,this._dispatcher=o,this._logger=i,V[t]=this}return t.of=function(t){return V[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 v(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(S).poll]}}))}))},t.prototype.create=function(t){return _(this,void 0,void 0,(function(){var n,e;return v(this,(function(o){switch(o.label){case 0:return g(E(t)).throw(I.invalidParameters),n=new P(w({},t)),[4,this._requestQueue.send(n)];case 1:return e=o.sent(),[2,e.as(x).poll]}}))}))},t.prototype.getOption=function(t){return _(this,void 0,void 0,(function(){var n,e;return v(this,(function(o){switch(o.label){case 0:return g(G(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=m.SYNC_POLL_CHANGELOGS),_(this,void 0,void 0,(function(){var s,a,i,r,l,u,c;return v(this,(function(h){switch(h.label){case 0:return s=new C(U({channelType:n,channelUrl:t,timestamp:"number"==typeof e?e:null,token:"string"==typeof e?e:null})),[4,this._requestQueue.send(s)];case 1:return a=h.sent(),i=a.as(M),r=i.updatedPolls,l=i.deletedPollIds,u=i.hasMore,c=i.nextToken,r.length>0&&this._dispatcher.dispatch(new y({polls:r,source:o})),[2,{updatedPolls:r,deletedPollIds:l,hasMore:u,token:c}]}}))}))},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,a=t.channelType,i=t.token,r=t.limit,l=o.call(this)||this;return l.method=n.GET,l.path=e,l.params={channel_url:s,channel_type:a,token:i,limit:r},l}return t(s,o),s}(o),F=function(n){function e(t,e){var o,a=this;return(a=n.call(this,t,e)||this).polls=(null!==(o=e.polls)&&void 0!==o?o:[]).map((function(n){return new s(t,n)})),a.token=e.next,a}return t(e,n),e}(a),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,a;return v(this,(function(i){switch(i.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,t=k.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=i.sent(),o=e.as(F),s=o.polls,a=o.token,this._token=a,this._hasNext=!!a,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),Y=function(o){function s(t){var s=t.channelUrl,a=t.channelType,i=t.pollId,r=t.pollOptionId,l=t.token,u=t.limit,c=o.call(this)||this;return c.method=n.GET,c.path="".concat(e,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(r),"/voters"),c.params={channel_url:s,channel_type:a,token:l,limit:u},c}return t(s,o),s}(o),J=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 b(t,n)})),s.token=e.next,s}return t(e,n),e}(a),K=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,a;return v(this,(function(i){switch(i.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,t=k.of(this._iid).requestQueue,n=new Y(w(w({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),[4,t.send(n)]):[3,2]:[3,5];case 1:return e=i.sent(),o=e.as(J),s=o.voters,a=o.token,this._token=a,this._hasNext=!!a,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,K as a,B as b,Q as c,N as d,R as e,A as f,G as g,j as h,z as i,E as v}; +import{_ as t,A as n,au as e,f as o,a8 as s,h as a,ao as i,ab as r,e as l,a as u,av as c,aw as h,Q as p,M as d,w as f,b as _,c as v,ai as m,t as g,S as I,g as w,ax as y,u as U,am as T,V as k,U as b}from"./__bundle-087816c3.js";var P=function(o){function s(t){var s=t.title,a=t.optionTexts,i=t.data,r=t.allowUserSuggestion,l=t.allowMultipleVotes,u=t.closeAt,c=o.call(this)||this;return c.method=n.POST,c.path=e,c.params={title:s,options:a,data:i,allow_user_suggestion:r,allow_multiple_votes:l,close_at:u},c}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}(a),O=function(o){function s(t){var s=t.channelUrl,a=t.channelType,i=t.pollId,r=o.call(this)||this;return r.method=n.GET,r.path="".concat(e,"/").concat(encodeURIComponent(i)),r.params={channel_url:s,channel_type:a},r}return t(s,o),s}(o),S=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}(a),q=function(o){function s(t){var s=t.channelUrl,a=t.channelType,i=t.pollId,r=t.pollOptionId,l=o.call(this)||this;return l.method=n.GET,l.path="".concat(e,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(r)),l.params={channel_url:s,channel_type:a},l}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 i(t,e),o}return t(e,n),e}(a),C=function(e){function o(t){var o=t.channelType,s=t.channelUrl,a=t.timestamp,i=t.token,u=e.call(this)||this;return u.method=n.GET,u.path="".concat(r(o),"/").concat(encodeURIComponent(s),"/polls/changelogs"),u.params=l({change_ts:a,token:i}),u}return t(o,e),o}(o),M=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 new s(t,n)}(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}(a),Q={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},E=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)},A={channelUrl:"",channelType:p.BASE,pollId:0,pollOptionId:0},G=function(t){return u("string",t.channelUrl)&&""!==t.channelUrl&&d(p,t.channelType)&&u("number",t.pollId)&&t.pollId>0&&u("number",t.pollOptionId)&&t.pollOptionId>0},N={channelUrl:"",channelType:p.BASE,pollId:0},R=function(t){return u("string",t.channelUrl)&&""!==t.channelUrl&&d(p,t.channelType)&&u("number",t.pollId)},V={},B=function(){function t(t,n){var e=n.sdkState,o=n.dispatcher,s=n.sessionManager,a=n.requestQueue,i=n.logger;this._iid=t,this._sdkState=e,this._sessionManager=s,this._requestQueue=a,this._dispatcher=o,this._logger=i,V[t]=this}return t.of=function(t){return V[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 v(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(S).poll]}}))}))},t.prototype.create=function(t){return _(this,void 0,void 0,(function(){var n,e;return v(this,(function(o){switch(o.label){case 0:return g(E(t)).throw(I.invalidParameters),n=new P(w({},t)),[4,this._requestQueue.send(n)];case 1:return e=o.sent(),[2,e.as(x).poll]}}))}))},t.prototype.getOption=function(t){return _(this,void 0,void 0,(function(){var n,e;return v(this,(function(o){switch(o.label){case 0:return g(G(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=m.SYNC_POLL_CHANGELOGS),_(this,void 0,void 0,(function(){var s,a,i,r,l,u,c;return v(this,(function(h){switch(h.label){case 0:return s=new C(U({channelType:n,channelUrl:t,timestamp:"number"==typeof e?e:null,token:"string"==typeof e?e:null})),[4,this._requestQueue.send(s)];case 1:return a=h.sent(),i=a.as(M),r=i.updatedPolls,l=i.deletedPollIds,u=i.hasMore,c=i.nextToken,r.length>0&&this._dispatcher.dispatch(new y({polls:r,source:o})),[2,{updatedPolls:r,deletedPollIds:l,hasMore:u,token:c}]}}))}))},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,a=t.channelType,i=t.token,r=t.limit,l=o.call(this)||this;return l.method=n.GET,l.path=e,l.params={channel_url:s,channel_type:a,token:i,limit:r},l}return t(s,o),s}(o),F=function(n){function e(t,e){var o,a=this;return(a=n.call(this,t,e)||this).polls=(null!==(o=e.polls)&&void 0!==o?o:[]).map((function(n){return new s(t,n)})),a.token=e.next,a}return t(e,n),e}(a),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,a;return v(this,(function(i){switch(i.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,t=k.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=i.sent(),o=e.as(F),s=o.polls,a=o.token,this._token=a,this._hasNext=!!a,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),Y=function(o){function s(t){var s=t.channelUrl,a=t.channelType,i=t.pollId,r=t.pollOptionId,l=t.token,u=t.limit,c=o.call(this)||this;return c.method=n.GET,c.path="".concat(e,"/").concat(encodeURIComponent(i),"/options/").concat(encodeURIComponent(r),"/voters"),c.params={channel_url:s,channel_type:a,token:l,limit:u},c}return t(s,o),s}(o),J=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 b(t,n)})),s.token=e.next,s}return t(e,n),e}(a),K=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,a;return v(this,(function(i){switch(i.label){case 0:return this._validate()?this._isLoading?[3,3]:this._hasNext?(this._isLoading=!0,t=k.of(this._iid).requestQueue,n=new Y(w(w({},this),{pollId:this.pollId,pollOptionId:this.pollOptionId,token:this._token})),[4,t.send(n)]):[3,2]:[3,5];case 1:return e=i.sent(),o=e.as(J),s=o.voters,a=o.token,this._token=a,this._hasNext=!!a,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,K as a,B as b,Q as c,N as d,R as e,A as f,G as g,j as h,z as i,E as v}; diff --git a/lib/__bundle-b8f76515.js b/lib/__bundle-b8f76515.js new file mode 100644 index 0000000..dacbb10 --- /dev/null +++ b/lib/__bundle-b8f76515.js @@ -0,0 +1 @@ +var t="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{},e="URLSearchParams"in t,r="Symbol"in t&&"iterator"in Symbol,o="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),n="FormData"in t,s="ArrayBuffer"in t;if(s)var i=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],a=ArrayBuffer.isView||function(t){return t&&i.indexOf(Object.prototype.toString.call(t))>-1};function h(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||""===t)throw new TypeError('Invalid character in header field name: "'+t+'"');return t.toLowerCase()}function u(t){return"string"!=typeof t&&(t=String(t)),t}function f(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return r&&(e[Symbol.iterator]=function(){return e}),e}function d(t){this.map={},t instanceof d?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){if(2!=t.length)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+t.length);this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function c(t){if(!t._noBody)return t.bodyUsed?Promise.reject(new TypeError("Already read")):void(t.bodyUsed=!0)}function y(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function l(t){var e=new FileReader,r=y(e);return e.readAsArrayBuffer(t),r}function p(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(t){var r;this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:o&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:n&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:e&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():s&&o&&((r=t)&&DataView.prototype.isPrototypeOf(r))?(this._bodyArrayBuffer=p(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s&&(ArrayBuffer.prototype.isPrototypeOf(t)||a(t))?this._bodyArrayBuffer=p(t):this._bodyText=t=Object.prototype.toString.call(t):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):e&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o&&(this.blob=function(){var t=c(this);if(t)return t;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 t=c(this);return t||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}if(o)return this.blob().then(l);throw new Error("could not read as ArrayBuffer")},this.text=function(){var t,e,r,o,n,s=c(this);if(s)return s;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=y(e),o=/charset=([A-Za-z0-9_-]+)/.exec(t.type),n=o?o[1]:"utf-8",e.readAsText(t,n),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),o=0;o-1?n:o),this.mode=r.mode||this.mode||null,this.signal=r.signal||this.signal||function(){if("AbortController"in t)return(new AbortController).signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&s)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(s),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==r.cache&&"no-cache"!==r.cache)){var i=/([?&])_=[^&]*/;if(i.test(this.url))this.url=this.url.replace(i,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function g(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),o=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(o),decodeURIComponent(n))}})),e}function v(t,e){if(!(this instanceof v))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===e.statusText?"":""+e.statusText,this.headers=new d(e.headers),this.url=e.url||"",this._initBody(t)}w.prototype.clone=function(){return new w(this,{body:this._bodyInit})},b.call(w.prototype),b.call(v.prototype),v.prototype.clone=function(){return new v(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},v.error=function(){var t=new v(null,{status:200,statusText:""});return t.status=0,t.type="error",t};var A=[301,302,303,307,308];v.redirect=function(t,e){if(-1===A.indexOf(e))throw new RangeError("Invalid status code");return new v(null,{status:e,headers:{location:t}})};var T=t.DOMException;try{new T}catch(t){(T=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack}).prototype=Object.create(Error.prototype),T.prototype.constructor=T}function _(e,r){return new Promise((function(n,i){var a=new w(e,r);if(a.signal&&a.signal.aborted)return i(new T("Aborted","AbortError"));var f=new XMLHttpRequest;function c(){f.abort()}if(f.onload=function(){var t=f.getAllResponseHeaders(),e=f.getResponseHeader("set-cookie");e&&(t=t.replace(e,e.replace(/\r?\n/g,", ")));var r,o,s={status:f.status,statusText:f.statusText,headers:(r=t||"",o=new d,r.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(t){return 0===t.indexOf("\n")?t.substr(1,t.length):t})).forEach((function(t){var e=t.split(":"),r=e.shift().trim();if(r){var n=e.join(":").trim();try{o.append(r,n)}catch(t){console.warn("Response "+t.message)}}})),o)};s.url="responseURL"in f?f.responseURL:s.headers.get("X-Request-URL");var i="response"in f?f.response:f.responseText;setTimeout((function(){n(new v(i,s))}),0)},f.onerror=function(){setTimeout((function(){i(new TypeError("Network request failed"))}),0)},f.ontimeout=function(){setTimeout((function(){i(new TypeError("Network request failed"))}),0)},f.onabort=function(){setTimeout((function(){i(new T("Aborted","AbortError"))}),0)},f.open(a.method,function(e){try{return""===e&&t.location.href?t.location.href:e}catch(t){return e}}(a.url),!0),"include"===a.credentials?f.withCredentials=!0:"omit"===a.credentials&&(f.withCredentials=!1),"responseType"in f&&(o?f.responseType="blob":s&&(f.responseType="arraybuffer")),r&&"object"==typeof r.headers&&!(r.headers instanceof d||t.Headers&&r.headers instanceof t.Headers)){var y=[];Object.getOwnPropertyNames(r.headers).forEach((function(t){y.push(h(t)),f.setRequestHeader(t,u(r.headers[t]))})),a.headers.forEach((function(t,e){-1===y.indexOf(e)&&f.setRequestHeader(e,t)}))}else a.headers.forEach((function(t,e){f.setRequestHeader(e,t)}));a.signal&&(a.signal.addEventListener("abort",c),f.onreadystatechange=function(){4===f.readyState&&a.signal.removeEventListener("abort",c)}),f.send(void 0===a._bodyInit?null:a._bodyInit)}))}_.polyfill=!0,t.fetch||(t.fetch=_,t.Headers=d,t.Request=w,t.Response=v); diff --git a/lib/__bundle-8fdac8b9.js b/lib/__bundle-cd6df760.js similarity index 71% rename from lib/__bundle-8fdac8b9.js rename to lib/__bundle-cd6df760.js index f5a56b2..9d5b4dc 100644 --- a/lib/__bundle-8fdac8b9.js +++ b/lib/__bundle-cd6df760.js @@ -1 +1 @@ -import{_ as t,U as i}from"./__bundle-75942676.js";var s=function(i){function s(t,s){var r,u=this;return(u=i.call(this,t,s)||this).isMuted=!1,u.isMuted=null!==(r=s.is_muted)&&void 0!==r&&r,u}return t(s,i),s}(i);export{s as P}; +import{_ as t,U as i}from"./__bundle-087816c3.js";var s=function(i){function s(t,s){var r,u=this;return(u=i.call(this,t,s)||this).isMuted=!1,u.isMuted=null!==(r=s.is_muted)&&void 0!==r&&r,u}return t(s,i),s}(i);export{s as P}; diff --git a/lib/__bundle-361d5a90.js b/lib/__bundle-dddddac5.js similarity index 95% rename from lib/__bundle-361d5a90.js rename to lib/__bundle-dddddac5.js index 13c504b..6e24453 100644 --- a/lib/__bundle-361d5a90.js +++ b/lib/__bundle-dddddac5.js @@ -1 +1 @@ -import{Q as e,_ as n,W as t,U as a,V as s,ac as r,aB as o,u as E,aP as N,n as i}from"./__bundle-75942676.js";import{r as u,R as _,s as l}from"./__bundle-84f74e8d.js";import{h as C}from"./__bundle-ad161b2c.js";var d;!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"}(d||(d={}));var h=function(){function n(e){var n;this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=null!==(n=e.data)&&void 0!==n?n:{},this.ts=e.ts}return Object.defineProperty(n.prototype,"isGroupChannelEvent",{get:function(){return this.channelType===e.GROUP},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isOpenChannelEvent",{get:function(){return this.channelType===e.OPEN},enumerable:!1,configurable:!0}),n}(),A=function(e){function t(n,t,a){var s=e.call(this,n,"SYEV",a)||this;return s.event=new h(a),s}return n(t,e),t}(t),c=function(e){function t(n,t,s){var r=e.call(this,n,t,s)||this,o=s.data.operators,E=void 0===o?[]:o;return r.operators=E.map((function(e){return new a(r._iid,e)})),r}return n(t,e),t}(A),p=function(e){function t(n,t,a){var s=e.call(this,n,"MCNT",a)||this;return s.groupChannelMemberCounts=a.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),s.openChannelMemberCounts=a.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),s}return n(t,e),t}(t),H=function(e){function t(n,t,a){var o,E,N,i,_=this;(_=e.call(this,n,"ADMM",a)||this).message=new u(n,a);var l=s.of(n).sdkState;return _.isMentioned=r(_.message.mentionType,null!==(N=null!==(o=_.message.mentionedUserIds)&&void 0!==o?o:null===(E=_.message.mentionedUsers)||void 0===E?void 0:E.map((function(e){return e.userId})))&&void 0!==N?N:[],l.userId),_.forceUpdateLastMessage=null!==(i=a.force_update_last_message)&&void 0!==i&&i,_}return n(t,e),t}(t),T=function(e){function t(n,t,a){var r,N,i,_,l,C=this;(C=e.call(this,n,"AEDI",a)||this).message=new u(n,a);var d=s.of(n).sdkState;return C.mentionCountChange=o({mentionType:null===(r=a.old_values)||void 0===r?void 0:r.mention_type,mentionedUserIds:null!==(i=null===(N=a.old_values)||void 0===N?void 0:N.mentioned_user_ids)&&void 0!==i?i:[]},E({mentionType:C.message.mentionType,mentionedUserIds:null!==(_=C.message.mentionedUserIds)&&void 0!==_?_:null===(l=C.message.mentionedUsers)||void 0===l?void 0:l.map((function(e){return e.userId}))}),d.userId),C}return n(t,e),t}(t),U=function(e){function t(n,t,a){var s=e.call(this,n,"MRCT",a)||this;return s.channelUrl=a.channel_url,s.channelType=a.channel_type,s.event=new _(a),s}return n(t,e),t}(t),L=function(e){function t(n,t,a){var s=e.call(this,n,"MTHD",a)||this;return s.event=new l(n,a),s}return n(t,e),t}(t),m=function(e){function t(n,t,a){var s=e.call(this,n,"PEDI",a)||this;return s.event=new C(n,a),s.status=N(a.poll.status)||a.poll.status,s.channelUrl=a.channel_url,s.channelType=a.channel_type,s}return n(t,e),t}(t),f=function(){this.onUserMuted=i,this.onUserUnmuted=i,this.onUserBanned=i,this.onUserUnbanned=i,this.onChannelChanged=i,this.onChannelDeleted=i,this.onChannelFrozen=i,this.onChannelUnfrozen=i,this.onOperatorUpdated=i,this.onChannelMemberCountChanged=i,this.onMetaDataCreated=i,this.onMetaDataUpdated=i,this.onMetaDataDeleted=i,this.onMetaCounterCreated=i,this.onMetaCounterUpdated=i,this.onMetaCounterDeleted=i,this.onMessageReceived=i,this.onMessageUpdated=i,this.onMessageDeleted=i,this.onMentionReceived=i,this.onReactionUpdated=i,this.onThreadInfoUpdated=i};export{H as A,f as B,A as C,p as M,c as O,m as P,U as R,L as T,T as U,d as a}; +import{Q as e,_ as n,W as t,U as a,V as s,ac as r,aB as o,u as E,aP as N,n as i}from"./__bundle-087816c3.js";import{r as u,R as _,s as l}from"./__bundle-80fd264e.js";import{h as C}from"./__bundle-8f39cad4.js";var d;!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"}(d||(d={}));var h=function(){function n(e){var n;this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=null!==(n=e.data)&&void 0!==n?n:{},this.ts=e.ts}return Object.defineProperty(n.prototype,"isGroupChannelEvent",{get:function(){return this.channelType===e.GROUP},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isOpenChannelEvent",{get:function(){return this.channelType===e.OPEN},enumerable:!1,configurable:!0}),n}(),A=function(e){function t(n,t,a){var s=e.call(this,n,"SYEV",a)||this;return s.event=new h(a),s}return n(t,e),t}(t),c=function(e){function t(n,t,s){var r=e.call(this,n,t,s)||this,o=s.data.operators,E=void 0===o?[]:o;return r.operators=E.map((function(e){return new a(r._iid,e)})),r}return n(t,e),t}(A),p=function(e){function t(n,t,a){var s=e.call(this,n,"MCNT",a)||this;return s.groupChannelMemberCounts=a.group_channels.map((function(e){return{channelUrl:e.channel_url,memberCount:e.member_count,joinedMemberCount:e.joined_member_count,updatedAt:e.ts}})),s.openChannelMemberCounts=a.open_channels.map((function(e){return{channelUrl:e.channel_url,participantCount:e.participant_count,updatedAt:e.ts}})),s}return n(t,e),t}(t),H=function(e){function t(n,t,a){var o,E,N,i,_=this;(_=e.call(this,n,"ADMM",a)||this).message=new u(n,a);var l=s.of(n).sdkState;return _.isMentioned=r(_.message.mentionType,null!==(N=null!==(o=_.message.mentionedUserIds)&&void 0!==o?o:null===(E=_.message.mentionedUsers)||void 0===E?void 0:E.map((function(e){return e.userId})))&&void 0!==N?N:[],l.userId),_.forceUpdateLastMessage=null!==(i=a.force_update_last_message)&&void 0!==i&&i,_}return n(t,e),t}(t),T=function(e){function t(n,t,a){var r,N,i,_,l,C=this;(C=e.call(this,n,"AEDI",a)||this).message=new u(n,a);var d=s.of(n).sdkState;return C.mentionCountChange=o({mentionType:null===(r=a.old_values)||void 0===r?void 0:r.mention_type,mentionedUserIds:null!==(i=null===(N=a.old_values)||void 0===N?void 0:N.mentioned_user_ids)&&void 0!==i?i:[]},E({mentionType:C.message.mentionType,mentionedUserIds:null!==(_=C.message.mentionedUserIds)&&void 0!==_?_:null===(l=C.message.mentionedUsers)||void 0===l?void 0:l.map((function(e){return e.userId}))}),d.userId),C}return n(t,e),t}(t),U=function(e){function t(n,t,a){var s=e.call(this,n,"MRCT",a)||this;return s.channelUrl=a.channel_url,s.channelType=a.channel_type,s.event=new _(a),s}return n(t,e),t}(t),L=function(e){function t(n,t,a){var s=e.call(this,n,"MTHD",a)||this;return s.event=new l(n,a),s}return n(t,e),t}(t),m=function(e){function t(n,t,a){var s=e.call(this,n,"PEDI",a)||this;return s.event=new C(n,a),s.status=N(a.poll.status)||a.poll.status,s.channelUrl=a.channel_url,s.channelType=a.channel_type,s}return n(t,e),t}(t),f=function(){this.onUserMuted=i,this.onUserUnmuted=i,this.onUserBanned=i,this.onUserUnbanned=i,this.onChannelChanged=i,this.onChannelDeleted=i,this.onChannelFrozen=i,this.onChannelUnfrozen=i,this.onOperatorUpdated=i,this.onChannelMemberCountChanged=i,this.onMetaDataCreated=i,this.onMetaDataUpdated=i,this.onMetaDataDeleted=i,this.onMetaCounterCreated=i,this.onMetaCounterUpdated=i,this.onMetaCounterDeleted=i,this.onMessageReceived=i,this.onMessageUpdated=i,this.onMessageDeleted=i,this.onMentionReceived=i,this.onReactionUpdated=i,this.onThreadInfoUpdated=i};export{H as A,f as B,A as C,p as M,c as O,m as P,U as R,L as T,T as U,d as a}; diff --git a/lib/__bundle-fd51cf65.js b/lib/__bundle-fd51cf65.js deleted file mode 100644 index 5eafa66..0000000 --- a/lib/__bundle-fd51cf65.js +++ /dev/null @@ -1 +0,0 @@ -import{a7 as e,a2 as t,ag as n,b as r,K as i,c as s,g as a,a as o,i as c,_ as u,S as l,a0 as h,t as d,aq as f,a5 as _,ar as v,x as p,y as m,ad as y,aj as b,ai as E,U as g,W as N,r as I,s as w,as as A,at as T}from"./__bundle-75942676.js";import{U as O,s as C,v as S,j as L,k,l as R,m as x,n as D,F as P,o as M,b as B,D as H}from"./__bundle-e875840b.js";import{S as U,U as V,F as K,b as q,c as F}from"./__bundle-84f74e8d.js";var j,G,z;!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"}(j||(j={})),function(e){e.CHRONOLOGICAL="chronological",e.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",e.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical"}(G||(G={})),function(e){e.CREATED_AT="created_at",e.SCHEDULED_AT="scheduled_at"}(z||(z={}));var W,Y=function(e){switch(e){case j.LATEST_LAST_MESSAGE:return["-lastMessageUpdatedAt","-createdAt","syncIndex"];case j.CHRONOLOGICAL:return["-createdAt","syncIndex"];case j.CHANNEL_NAME_ALPHABETICAL:return["name"];default:return["-lastMessageUpdatedAt","-createdAt","syncIndex"]}},Q=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 U))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 U&&r.parentMessageId>0&&!r.replyToChannel)return!1}return!0},r}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(W||(W={}));var J,Z,X=function(e){switch(e){case W.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case W.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},$=function(){return"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product},ee=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"}(J||(J={})),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"}(Z||(Z={}));var te,ne={},re=function(){function e(e,t){void 0===t&&(t={});var n=this;return this._state=J.PROCESSING,this._queue=[],this._activationQueue=[],ne[e]&&!t.forceCreate||(this.nodeId=ee(),this.key=e,$()&&(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 Z.NEWNODE:n._sendSync();break;case Z.CLAIM_HOST:n._sendSync(),n._hostId=a;break;case Z.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:Z.REQUEST_LOCK,ts:e.ts})};try{for(var v=i(f),p=v.next();!p.done;p=v.next()){_(p.value)}}catch(e){t={error:e}}finally{try{p&&!p.done&&(r=v.return)&&r.call(v)}finally{if(t)throw t.error}}n._currentItem=n._queue.find((function(e){return e.requestId===d})),n._completeSync()}break;case Z.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 Z.REQUEST_LOCK:n._requestLock(s);break;case Z.ACQUIRE_LOCK:var m=n._queue.find((function(e){return e.requestId===o}));n._acquire(m);break;case Z.RELEASE_LOCK:n._release(o)}})),window.addEventListener("beforeunload",(function(){n._send(Z.REMOVENODE)}))),ne[e]=this),ne[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==J.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:ee(),key:this.key,op:e,data:t.data,ts:Date.now()};return $()&&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(Z.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(Z.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(Z.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=J.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])},e.prototype.registerNode=function(){this._send(Z.NEWNODE),this._waitSync()},e.prototype.claimHost=function(){this._hostId=this.nodeId,this._send(Z.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(Z.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}(),ie=a(a({},O),{scheduledAt:void 0}),se=function(e){return S(e)&&o("number",e.scheduledAt,!0)},ae=a(a({},L),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),oe=function(e){return R(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})))},ce="UnsentMessage",ue="reqId",le={},he=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,le[t]=s,s._mutex=new re("unsendmessagecache.lock"),s}return u(t,e),t.of=function(e){return le[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb,t=null==e?void 0:e.collection(ce);if(!t)throw l.databaseError;return t},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=C(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,a(a({},C(t)),{scheduledAt:t.scheduledAt})))):e instanceof K?(e.messageParams&&(n.messageParams=k(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return a(a({},k(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))):e instanceof q&&e.messageParams&&(n.messageParams=x(e.messageParams)),n},t.prototype._deserialize=function(e){return e=a(a({},e),{messageId:parseInt(e.messageId)}),F.of(this._iid).buildMessageFromSerializedData(e)},t.prototype._deserializeWithMessageCreateParams=function(e){var t,n,i;return r(this,void 0,void 0,(function(){var a,o,c,u,l,h,d=this;return s(this,(function(f){switch(f.label){case 0:return a=F.of(this._iid),o=this._deserialize(e),e.messageParams?o instanceof V?(u=e.messageParams,o.messageParams=a.buildUserMessageCreateParamsFromSerializedData(u,o),[3,6]):[3,1]:[3,6];case 1:return o instanceof K?(u=e.messageParams).fileKey&&"string"==typeof u.fileKey&&D(null!==(t=u.fileType)&&void 0!==t?t:"")?(c=u,[4,this.collection.getBlob(u.fileKey)]):[3,3]:[3,4];case 2:c.file=null!==(n=f.sent())&&void 0!==n?n:void 0,f.label=3;case 3:return o.messageParams=a.buildFileMessageCreateParamsFromSerializedData(u,o),[3,6];case 4:return o instanceof q&&((u=e.messageParams)&&u.fileInfoList)?(o.messageParams=a.buildMultipleFilesMessageCreateParamsFromSerializedData(u,o),[4,Promise.all(o.messageParams.fileInfoList.map((function(e){return r(d,void 0,void 0,(function(){var t,n,r,i,a;return s(this,(function(s){switch(s.label){case 0:return"string"==typeof(null===(n=e._uploadedMetaData)||void 0===n?void 0:n.fileKey)&&D(null!==(i=null===(r=e._uploadedMetaData)||void 0===r?void 0:r.fileType)&&void 0!==i?i:"")?(t=e,[4,this.collection.getBlob(e._uploadedMetaData.fileKey)]):[3,2];case 1:t.file=null!==(a=s.sent())&&void 0!==a?a:void 0,s.label=2;case 2:return[2]}}))}))})))]):[3,6];case 5:f.sent(),f.label=6;case 6:return o.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams?o instanceof V?(l=e.scheduledInfo.scheduledMessageParams,o.scheduledInfo.scheduledMessageParams=a.buildScheduledUserMessageCreateParamsFromSerializedData(l,o),[3,10]):[3,7]:[3,10];case 7:return o instanceof K?(l=e.scheduledInfo.scheduledMessageParams).fileKey&&"string"==typeof l.fileKey&&"string"==typeof l.fileType&&D(l.fileType)?(h=l,[4,this.collection.getBlob(l.fileKey)]):[3,9]:[3,10];case 8:h.file=null!==(i=f.sent())&&void 0!==i?i:void 0,f.label=9;case 9:o.scheduledInfo.scheduledMessageParams=a.buildScheduledFileMessageCreateParamsFromSerializedData(l,o),f.label=10;case 10:return[2,o]}}))}))},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,void 0]}}))}))},t.prototype.fetch=function(e){var t=e.channelUrl,n=e.filter,i=void 0===n?new Q:n,a=e.order,o=void 0===a?W.CHANNEL_LATEST:a,c=e.sendingStatus,u=e.backward,l=void 0!==u&&u,h=e.parentMessageId;return r(this,void 0,void 0,(function(){var e,n,a,u,d=this;return s(this,(function(f){switch(f.label){case 0:return this.localCacheEnabled?(e=X(o),n={"/where":function(e){return!!(o!==W.NEWEST_CHILD_MESSAGE||h&&0!==e.parentMessageId&&e.parentMessageId===h)&&i.match(d._deserialize(e))}},t&&(n.channelUrl=t),c&&(n.sendingStatus=c),a={where:n,index:e,backward:l},[4,this.collection.query(a)]):[3,3];case 1:return[4,f.sent().fetch({})];case 2:return u=f.sent(),[2,Promise.all(u.map((function(e){return r(d,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 Q),r(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,this.fetch({filter:t,order:W.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 q?[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;return s(this,(function(n){switch(n.label){case 0:return t=[],e.threadInfo&&e.threadInfo.replyCount>0?[4,this.getAllChildMessages(e)]:[3,2];case 1:t=n.sent(),n.label=2;case 2:return t.length>0?(t.forEach((function(t){return t.applyParentMessage(e)})),[4,this.upsert(t)]):[3,4];case 3:n.sent(),n.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&&M(i.file)?[4,this.collection.saveBlob(i.file,e.reqId)]:[3,2]:[3,5];case 1:n=o.sent(),i.fileKey=n,i.fileType=P.BLOB,o.label=2;case 2:return e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&((t=e.scheduledInfo.scheduledMessageParams).file&&M(t.file))?[4,this.collection.saveBlob(t.file,e.reqId)]:[3,4];case 3:n=o.sent(),t.fileKey=n,t.fileType=P.BLOB,o.label=4;case 4:return[3,7];case 5:return e instanceof q&&((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;return s(this,(function(i){switch(i.label){case 0:return t.file&&M(t.file)?[4,this.collection.saveBlob(t.file,this._getFileInfoBlobKey(e.reqId,n))]:[3,2];case 1:r=i.sent(),t._uploadedMetaData||(t._uploadedMetaData={}),t._uploadedMetaData.fileKey=r,t._uploadedMetaData.fileType=P.BLOB,i.label=2;case 2:return[2]}}))}))})))]:[3,7];case 6:o.sent(),o.label=7;case 7:return[2]}}))}))},t}(h),de={},fe=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,de[t]=a,a}return u(t,e),t.of=function(e){return de[e]},Object.defineProperty(t.prototype,"collection",{get:function(){var e=this._cacheContext.nestdb;return d(!!e).throw(l.databaseError),e.collection(B)},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)}),F.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,void 0]}}))}))},t.prototype.fetch=function(e){var t=e.channelUrl,n=e.token,i=e.limit,a=void 0===i?H:i,o=e.filter,c=void 0===o?new Q:o,u=e.order,l=void 0===u?W.CHANNEL_LATEST:u,h=e.backward,d=void 0!==h&&h,f=e.parentMessageId,_=e.isPollOnly,v=void 0!==_&&_;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 W.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(W.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(W.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(W.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&&M(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),_e=function(e){function t(t){var n=t.message,r=e.call(this)||this;return r.message=n,r}return u(t,e),t}(f),ve={},pe=function(){function e(e,t){var n=t.localCacheEnabled,r=t.dispatcher,i=t.sdkState,s=t.logger,a=this;this._iid=e,ve[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 p)switch(e.stateType){case m.CONNECTED:a._isProcessingAutoResend||a.processAutoResendRegisteredPendingMessages().then((function(){return a._processNextAutoResend()}));break;case m.INTERNAL_DISCONNECTED:case m.EXTERNAL_DISCONNECTED:a._isProcessingAutoResend=!1}}))}return e.of=function(e){return ve[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=_.FAILED,r.errorCode=y.ACK_TIMEOUT,this._dispatcher.dispatch(new b({messages:[r],source:E.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&&v(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=_.FAILED,this._dispatcher.dispatch(new b({messages:[r],source:E.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===_.SUCCEEDED||e.sendingStatus===_.FAILED&&!v(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=he.of(this._iid))?[4,e.fetch({sendingStatus:_.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 _e({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"}(te||(te={}));var me,ye=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 g(e,r),blockee:new g(e,i)}},e.getDataAsFriendDiscoveredEvent=function(e,t){var n=t.data.friend_discoveries;return{friendDiscoveries:Array.isArray(n)?n.map((function(t){return new g(e,t)})):[]}},e}(),be=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}(f);!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"}(me||(me={}));var Ee,ge=function(e){return e.startsWith("EVENT_")||e===me.SYNC_CHANNEL_CHANGELOGS||e===me.REFRESH_CHANNEL},Ne=function(e){function t(t){var n=t.channels,r=t.source,i=t.isWebSocketEventComing,s=void 0!==i&&i,a=t.data,o=void 0===a?null:a,c=e.call(this)||this;return c.channels=n,c.source=r,c.isWebSocketEventComing=s,c.data=o,c}return u(t,e),t}(f),Ie=function(e){function t(t){var n=t.channelUrls,r=t.source,i=t.isWebSocketEventComing,s=void 0!==i&&i,a=e.call(this)||this;return a.channelUrls=n,a.source=r,a.isWebSocketEventComing=s,a}return u(t,e),t}(f),we=function(e){function t(){return e.call(this)||this}return u(t,e),t}(f),Ae=function(e){function t(t,n,r){var i=e.call(this,t,"USEV",r)||this;return i.event=new ye(r),i}return u(t,e),t}(N),Te={},Oe=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,v=void 0!==_&&_;return Te[t]||(this.itemSizeLimit=r,this.cacheLimit=s,this.blockHashBase=o,this.blockHashMultiplier=u,this.blockHashConstant=h,this.transactionApplyDelay=f,this.disableLogger=v,Te[t]=this),Te[t]}return e.get=function(e){return Te[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"}(Ee||(Ee={}));var Ce,Se=function(e){function t(n){var r=n.code,i=void 0===r?Ee.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:Ee.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:Ee.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:Ee.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:Ee.STORE_IS_FULL,message:"Store is full."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeNotInitialized",{get:function(){return new t({code:Ee.STORE_NOT_INITIALIZED,message:"Store is not initialized."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeKeyTypeIsInvalid",{get:function(){return new t({code:Ee.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:Ee.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:Ee.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:Ee.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:Ee.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:Ee.STORE_READ_FAILED,message:"Failed to read from store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"storeWriteFailed",{get:function(){return new t({code:Ee.STORE_WRITE_FAILED,message:"Failed to write to store."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"databaseSchemaNotOnUpgrade",{get:function(){return new t({code:Ee.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:Ee.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:Ee.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:Ee.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:Ee.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotFound",{get:function(){return new t({code:Ee.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionKeyNotGiven",{get:function(){return new t({code:Ee.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:Ee.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"collectionItemSizeExceeded",{get:function(){return new t({code:Ee.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:Ee.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"indexTypesNotMatch",{get:function(){return new t({code:Ee.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:Ee.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:Ee.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"}(Ce||(Ce={}));var Le,ke=function(e,t){if(void 0===t&&(t=new WeakMap),"object"==typeof e&&null!==e){if(t.has(e))throw Se.circularReferenceFound;t.set(e,!0);var n=void 0;if(Array.isArray(e))n=e.map((function(e){return ke(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]=ke(e[r],t);return t.delete(e),n}return e},Re=function(e,t){if(null==t)return 1;if(null==e)return-1;if(typeof e!=typeof t)throw Se.compareTypesNotMatch;var n=0;switch(typeof e){case"boolean":case"number":n=e-t;break;case"string":n=e.localeCompare(t)}return n},xe=function(e,t){for(var n=0,r=0;r>>0)%t},De=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Pe=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!Pe(e,t)})))return!1}else if(["/or","||"].includes(n)){if(e[n].every((function(e){return!Pe(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(!(Re(a,o)>0))return!1;break;case"/gte":case">=":a=t[r],o=i[s];if(!(Re(a,o)>=0))return!1;break;case"/lt":case"<":a=t[r],o=i[s];if(!(Re(a,o)<0))return!1;break;case"/lte":case"<=":a=t[r],o=i[s];if(!(Re(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)},Me=function(){},Be=function(){return Promise.resolve()},He=function(e){return e},Ue=function(e,t){t()};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Le||(Le={}));var Ve,Ke,qe,Fe=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?He:a,c=e.backward,u=void 0===c?Be:c,l=e.forward,h=void 0===l?Be:l,d=e.complete,f=void 0===d?Me: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}(),je=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*Re(this._indexer.origin[u].columnValues[i],this.condition[s][c])<=0){r=u;break}}else for(u=r;u>=0;u--)if(a*Re(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===qe.PERSISTENT&&(r.state=Ke.PERSISTENT),t!==qe.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)$e.includes(this._items[r].state)&&$e.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}(),nt=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(We(e,t),"/trans.metadata")}(t,n),this.recordsetKey=function(e,t){return"".concat(We(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,I([],w(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=tt.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=tt.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=rt.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=Oe.get(this.dbname),r=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/n.itemSizeLimit),[4,tt.get(this.dbname).find(this._store,r)];case 1:return a=s.sent(),(null==(o=a?rt.createFromCacheItem(a):new rt({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=Qe(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(),tt.get(this.dbname).clearByCondition((function(t){return t.key.startsWith(e)})),[2]}}))}))},e}(),st={},at=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(We(e,t),"/index.").concat(n)}(t,n,i.join(">"));return st[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()}))),st[c]}return e.createKey=function(e){return e.join(">")},e.parseKey=function(e){return e.split(">")},e.clearIndexerMap=function(){for(var e in st)delete st[e]},e.prototype._addItem=function(e){var t=e[this.keyName],n=this.getColumnValues(e),r=w(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=w(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 Se.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=Re(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,_,v,p,m,y;return s(this,(function(s){switch(s.label){case 0:return[4,(e=tt.get(this.dbname)).find(this._store,this.indexerKey,qe.PERSISTENT)];case 1:return(t=s.sent())?[3,11]:(n=Qe(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,qe.NO_CACHE)]:[3,6];case 5:if(u=s.sent(),l=rt.createFromCacheItem(u))try{for(m=void 0,h=i(l.items),d=h.next();!d.done;d=h.next())f=d.value,this._addItem(f)}catch(e){m={error:e}}finally{try{d&&!d.done&&(y=h.return)&&y.call(h)}finally{if(m)throw m.error}}s.label=6;case 6:return o=a.next(),[3,4];case 7:return[3,10];case 8:return _=s.sent(),v={error:_},[3,10];case 9:try{o&&!o.done&&(p=a.return)&&p.call(a)}finally{if(v)throw v.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=ke(this._origin),s.label=12;case 12:return st[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 tt.get(this.dbname).remove(this.indexerKey),[4,this._store.remove(this.indexerKey)];case 1:return e.sent(),delete st[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=ke(this._origin)},e.prototype.abort=function(){this._table=ke(this._origin)},e}(),ot=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=Ce.INIT,this._indexers=[],this.dbname=t,this.name=n,this.keyName=r,this.indexes=I([[r]],w(s.filter((function(e){return at.createKey(e)!==o.keyName}))),!1),this._keyHash=i,this._store=a,this._mutex=new re(function(e,t){return"".concat(We(e,t),".lock")}(t,n)),this._blobContainer=new Ze({dbname:t,collectionName:n,store:a}),this._transaction=new nt({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=Ye(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===Ce.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,_,v,p,m=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=Oe.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 it({dbname:this.dbname,collectionName:this.name,hashFunction:this._keyHash,metadata:this._metadata,transaction:this._transaction,store:this._store}),r=I([],w(this.indexes),!1),a=[],o=r.map((function(e){return at.createKey(e)})),c=n?n.indexes.map((function(e){return at.createKey(e)})):[];try{for(u=i(c),l=u.next();!l.done;l=u.next())h=l.value,o.includes(h)||a.push(at.parseKey(h))}catch(e){v={error:e}}finally{try{l&&!l.done&&(p=u.return)&&p.call(u)}finally{if(v)throw v.error}}return(d=[]).push.apply(d,I([],w(r.map((function(e){var t=new at({dbname:m.dbname,collectionName:m.name,keyName:m.keyName,fields:e,transaction:m._transaction,store:m._store});return m._indexers.push(t),t.ensure()}))),!1)),d.push.apply(d,I([],w(a.map((function(e){return new at({dbname:m.dbname,collectionName:m.name,keyName:m.keyName,fields:e,transaction:m._transaction,store:m._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=Ye(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=Ce.READY,this._mutex.unlock(),[3,10];case 9:throw _=s.sent(),this._mutex.unlock(),_;case 10:return[2]}}))}))},e.prototype.close=function(){this._state=Ce.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=at.createKey(e);try{for(var s=i(this._indexers),a=s.next();!a.done;a=s.next()){var o=a.value;if(r===at.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 Se.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=Ye(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 Se.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,_,v;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&&(v=c.return)&&v.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,ke(t)];case 4:throw n=r.sent(),this._mutex.unlock(),n;case 5:return[3,7];case 6:throw Se.collectionNotReady;case 7:return[2]}}))}))},e.prototype.query=function(e){if(void 0===e&&(e={}),this.isReady)return new Ge({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Se.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 Se.collectionKeyNotGiven;return[4,this._requestInsert(ke(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 Se.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 Se.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(ke(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 Se.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 Se.collectionKeyNotGiven;return[4,this._requestUpsert(ke(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 Se.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 Se.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(ke(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 Se.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 Se.collectionKeyNotGiven;return[4,this._requestUpdate(ke(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 Se.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,_,v,p,m,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 je({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,Pe(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(ke(_))]);case 6:E.sent(),E.label=7;case 7:return f=d.next(),[3,5];case 8:return[3,11];case 9:return v=E.sent(),m={error:v},[3,11];case 10:try{f&&!f.done&&(y=d.return)&&y.call(d)}finally{if(m)throw m.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(),Se.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 Se.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,_,v,p,m,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 je({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,Pe(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&&(m=h.return)&&m.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 v=b.sent(),this._mutex.unlock(),v;case 14:return[3,16];case 15:throw this._transaction.clear(),Se.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 Se.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}(),ct=function(){function e(e){var t,n,r;this.encryption=null!==(t=e.encryption)&&void 0!==t?t:A,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),I([],w(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 Se.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,I([],w(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,I([],w(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}(),ut={},lt=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 ut[this.dbname]},set:function(e){ut[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(ut[this.dbname])return[2,Object.keys(ut[this.dbname])];throw Se.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 ut[this.dbname]?[4,De(this.delay)]:[3,2];case 1:return t.sent(),[2,ut[this.dbname][e]?a({key:e},ut[this.dbname][e]):null];case 2:throw Se.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 ut[this.dbname]?[4,De(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,ut[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 Se.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 ut[this.dbname]?[4,De(this.delay)]:[3,2];case 1:s.sent();try{for(t=i(e),n=t.next();!n.done;n=t.next())r=n.value,ut[this.dbname][r]&&delete ut[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 Se.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,ut[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,De(this.delay)];case 1:return e.sent(),ut[this.dbname]={},[2]}}))}))},t}(ct),ht="NestDBStore";!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(Xe||(Xe={}));var dt=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=ht,r._state=Xe.UNINITIALIZED,r._openJobQueue=[],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),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),t.prototype._openDatabase=function(e){var t=this;return new Promise((function(n,r){if(t._indexedDb){t._state=Xe.OPENING;var i=t._indexedDb.open(e);i.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(ht,{keyPath:"key"})})),i.addEventListener("success",(function(r){t._state=Xe.OPEN,t._database=r.target.result,t._openJobQueue.forEach((function(e){return e()})),t._openJobQueue=[],t._database.onclose=function(){t._database=void 0,t._state=Xe.OPENING,setTimeout((function(){t._openDatabase(e)}),5)},n(t._database)})),i.addEventListener("error",(function(e){t._state=Xe.UNINITIALIZED,r(e.target.error)}))}else r(Se.storeNotAvailable)}))},t.prototype._getObjectStore=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._database?[2,this._database.transaction(this._storeName,e).objectStore(this._storeName)]:[3,1];case 1:switch(this._state){case Xe.UNINITIALIZED:case Xe.OPEN:return[3,2];case Xe.OPENING:case Xe.CLOSED:return[3,3]}return[3,4];case 2:throw Se.storeNotInitialized;case 3:return[2,new Promise((function(n){t._openJobQueue.push((function(){return n(t._getObjectStore(e))}))}))];case 4:return[4,this._getObjectStore(e)];case 5:return[2,n.sent()]}}))}))},t.prototype._getAllRawKeys=function(){return r(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return[4,this._getObjectStore("readonly")];case 1:return e=t.sent(),[4,new Promise((function(t,n){var r=e.getAllKeys();r.addEventListener("success",(function(e){t(e.target.result)})),r.addEventListener("error",(function(e){return n(e.target.error)}))}))];case 2:return[2,t.sent()]}}))}))},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._getObjectStore("readonly")];case 1:return t=n.sent(),[4,new Promise((function(n,r){var i=t.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 2: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[4,this._getObjectStore("readwrite")];case 1:return t=n.sent(),[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 2: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[4,this._getObjectStore("readwrite")];case 1:return t=n.sent(),[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 2:return n.sent(),[2]}}))}))},t.prototype._triggerDatabaseClose=function(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))},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||!$())return[3,4];if(!($()&&navigator.userAgent&&navigator.userAgent.includes("Edge/")))return[3,1];if(!this._window.indexedDB&&(e.PointerEvent||e.MSPointerEvent))throw Se.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(Se.storeNotAvailableInPrivateBrowsing)},r.onsuccess=function(){return e()}}catch(e){n(Se.storeNotAvailableInPrivateBrowsing)}else n(Se.storeNotAvailable)}))];case 2:n.sent(),n.label=3;case 3:return[3,5];case 4:throw Se.storeNotAvailable;case 5:return[3,7];case 6:throw Se.storeNotAvailable;case 7:return[2]}}))}))},t.prototype.init=function(e){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return this.dbname=e,[4,this.checkAvailability()];case 1:return t.sent(),[4,this._openDatabase(e)];case 2:return t.sent(),[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._getObjectStore("readwrite")];case 1:return e=t.sent(),[4,new Promise((function(t,n){var r=e.clear();r.addEventListener("success",(function(){return t()})),r.addEventListener("error",(function(e){return n(e.target.error)}))}))];case 2:return[2,t.sent()]}}))}))},t}(ct),ft=function(e){function t(t){var n=this,r=t.AsyncStorage,i=t.itemSizeLimit,s=void 0===i?6291456:i,o=T(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 Se.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}(ct);!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 Se.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]}}))}))}}(ct);var _t,vt="[NESTDB]",pt=!0,mt=function(){function e(){}return e.off=function(){pt=!1},e.log=function(){for(var e=[],t=0;t object; } -export declare type FailedMessageHandler = (err: Error | null, message: SendableMessage | null) => void; +export declare type FailedMessageHandler = (err: Error, message: SendableMessage | null) => void; export declare type FileCompat = File | Blob | FileInfo; @@ -509,6 +509,7 @@ export declare enum GroupChannelEventSource { EVENT_CHANNEL_ACCEPTED_INVITE = 'EVENT_CHANNEL_ACCEPTED_INVITE', EVENT_CHANNEL_DECLINED_INVITE = 'EVENT_CHANNEL_DECLINED_INVITE', EVENT_CHANNEL_OPERATOR_UPDATED = 'EVENT_CHANNEL_OPERATOR_UPDATED', + EVENT_CHANNEL_BANNED = 'EVENT_CHANNEL_BANNED', EVENT_CHANNEL_MUTED = 'EVENT_CHANNEL_MUTED', EVENT_CHANNEL_UNMUTED = 'EVENT_CHANNEL_UNMUTED', EVENT_CHANNEL_FROZEN = 'EVENT_CHANNEL_FROZEN', @@ -566,6 +567,12 @@ export declare class LocalCacheConfig { get clearOrderComparator(): Comparator; } +declare interface LocalCacheConfigParams { + maxSize?: number; + clearOrder?: CachedDataClearOrder; + customClearOrderComparator?: Comparator; +} + export declare enum LogLevel { NONE = 0, VERBOSE = 1, diff --git a/message.js b/message.js index 16cc86b..12fed74 100644 --- a/message.js +++ b/message.js @@ -1 +1 @@ -export{a4 as MentionType,a2 as MessageType,a7 as MessageTypeFilter,a9 as PushNotificationDeliveryOption,ag as ReplyType,a5 as SendingStatus}from"./lib/__bundle-75942676.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-84f74e8d.js"; +export{a4 as MentionType,a2 as MessageType,a7 as MessageTypeFilter,a9 as PushNotificationDeliveryOption,ag as ReplyType,a5 as SendingStatus}from"./lib/__bundle-087816c3.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-80fd264e.js"; diff --git a/openChannel.js b/openChannel.js index e91feec..4fb2ec9 100644 --- a/openChannel.js +++ b/openChannel.js @@ -1 +1 @@ -import{_ as e,b as n,c as t,a0 as r,m as a,a as i,i as o,A as s,aQ as u,aR as c,f as l,h,e as d,u as p,aa as f,U as v,W as C,x as _,y,K as m,w as U,aD as E,z as g,aE as w,ai as T,Q as M,aG as b,t as N,S as P,g as D,aK as H,am as O,V as x,a3 as I,n as A,B as R,an as L}from"./lib/__bundle-75942676.js";import{q as F,r as S,t as k,w as q,u as z,x as Q,y as K,P as V,z as j,A as B,C as G,E as W,f as X}from"./lib/__bundle-e875840b.js";import{C as Y,a as Z,O as $,P as J,M as ee,T as ne,R as te,U as re,A as ae,B as ie}from"./lib/__bundle-361d5a90.js";import{m as oe,c as se}from"./lib/__bundle-84f74e8d.js";import{P as ue}from"./lib/__bundle-8fdac8b9.js";import"./lib/__bundle-ad161b2c.js";var ce=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!!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){return n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,this._channels.get(e)]}))}))},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:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0},he=function(n){function t(e){var t=e.channelUrl,r=e.isInternalCall,a=n.call(this)||this;return a.method=s.GET,a.path="".concat(r?u:c,"/").concat(encodeURIComponent(t)),a}return e(t,n),t}(l),de=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new Ne(e,t),r}return e(t,n),t}(h),pe=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,l=e.data,h=e.customType,f=e.operatorUserIds,v=e.isEphemeral;return(t=n.call(this)||this).method=s.POST,t.path=c,t.params=d(p({channel_url:r,cover_url:i("string",a)?a:null,cover_file:o(a)?a:null,name:u,data:l,custom_type:h,operators:f,is_ephemeral:v})),t}return e(t,n),t}(l);!function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new Ne(e,t),r}e(t,n)}(h);var fe=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}(f),ve=function(n){function t(e,t,r){var a,i,o=this;return o=n.call(this,e,"SYEV",r)||this,r.data&&(o.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,o.user=new v(e,r.data),o.ts=null!==(i=r.data.edge_ts)&&void 0!==i?i:0),o}return e(t,n),t}(Y),Ce=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}(f),_e=function(n){function t(e,t,r){var a,i,o=this;return o=n.call(this,e,"EXIT",r)||this,r.data&&(o.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,o.user=new v(e,r.data),o.ts=null!==(i=r.data.edge_ts)&&void 0!==i?i:0),o}return e(t,n),t}(Y),ye={},me=function(){function e(e,n){var t=n.sdkState,r=n.dispatcher,a=n.requestQueue,i=this;return ye[e]||(this._iid=e,this._sdkState=t,this._requestQueue=a,this._dispatcher=r,this._openChannelCache=new ce(e),this._openChannelHandlers=new Map,this._dispatcher.on((function(e){var n,t;if(e instanceof C)i._handleEvent(e);else if(e instanceof _&&e.stateType===y.CONNECTED){var r=i._openChannelCache.enteredChannels;try{for(var a=m(r),o=a.next();!o.done;o=a.next()){o.value.enter()}}catch(e){n={error:e}}finally{try{o&&!o.done&&(t=a.return)&&t.call(a)}finally{if(n)throw n.error}}}})),ye[e]=this),ye[e]}return e.of=function(e){return ye[e]},e.prototype.buildOpenChannelFromSerializedData=function(e){var n=U(e);return new Ne(this._iid,Ne.payloadify(n))},e.prototype.getChannelFromCache=function(e){var r;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,null!==(r=n.sent())&&void 0!==r?r:null]}}))}))},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,o,s;return t(this,(function(t){switch(t.label){case 0:t.trys.push([0,5,6,7]),n=m(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(),o={error:i},[3,7];case 6:try{r&&!r.done&&(s=n.return)&&s.call(n)}finally{if(o)throw o.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,o,s,u,c,l,h,d,p,f,v,C,_,y,U,N,P,D,O,x,I,A,R,L,X,ie,se,ue,ce,le,he,de,pe,fe,Ce,ye,me,Ue,Ee,ge,we,Te,Me,be,Ne,Pe,De,He,Oe,xe,Ie,Ae,Re,Le,Fe,Se,ke,qe,ze,Qe,Ke,Ve,je,Be,Ge,We,Xe=this;return t(this,(function(Ye){switch(Ye.label){case 0:switch(Ye.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 o=null,"MESG"===e.code?o=e.as(W):"FILE"===e.code?o=e.as(oe):"ADMM"!==e.code&&"BRDM"!=e.code||(o=e.as(ae)),o?(r=o.message,a=o.isMentioned,r.channelType!==M.OPEN?[3,3]:[4,this.getChannel(r.channelUrl,!0)]):[3,3];case 2:i=Ye.sent(),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,o,s,u;return t(this,(function(t){try{for(e=m(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())o=n.value,this._openChannelCache.isEnteredChannel(i.url)&&(o.onMessageReceived&&o.onMessageReceived(i,r),a&&o.onMentionReceived&&o.onMentionReceived(i,r))}catch(e){s={error:e}}finally{try{n&&!n.done&&(u=e.return)&&u.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),Ye.label=3;case 3:return[3,56];case 4:return o=null,"MEDI"===e.code?o=e.as(B):"FEDI"===e.code?o=e.as(G):"AEDI"===e.code&&(o=e.as(re)),o?(s=o.message,u=o.mentionCountChange,s.channelType!==M.OPEN?[3,6]:[4,this.getChannel(s.channelUrl,!0)]):[3,6];case 5:c=Ye.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=m(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(c.url)&&(r.onMessageUpdated&&r.onMessageUpdated(c,s),u>0&&r.onMentionReceived&&r.onMentionReceived(c,s))}catch(e){a={error:e}}finally{try{n&&!n.done&&(i=e.return)&&i.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Ye.label=6;case 6:return[3,56];case 7:return l=e.as(j),ce=l.channelUrl,le=l.channelType,h=l.messageId,le!==M.OPEN?[3,9]:[4,this.getChannel(ce,!0)];case 8:d=Ye.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=m(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(d.url)&&r.onMessageDeleted&&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]}))}))})),Ye.label=9;case 9:return[3,56];case 10:return p=e.as(te),ce=p.channelUrl,le=p.channelType,f=p.event,le!==M.OPEN?[3,12]:[4,this.getChannel(ce,!0)];case 11:v=Ye.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=m(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(v.url)&&r.onReactionUpdated&&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]}))}))})),Ye.label=12;case 12:return[3,56];case 13:return(C=e.as(ne).event).channelType!==M.OPEN?[3,15]:[4,this.getChannel(C.channelUrl,!0)];case 14:_=Ye.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=m(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(_.url)&&r.onThreadInfoUpdated&&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]}))}))})),Ye.label=15;case 15:return[3,56];case 16:y=e.as(ee).openChannelMemberCounts,U=[],Ye.label=17;case 17:Ye.trys.push([17,22,23,24]),N=m(y),P=N.next(),Ye.label=18;case 18:return P.done?[3,21]:(D=P.value,ce=D.channelUrl,Ee=D.participantCount,O=D.updatedAt,[4,this.getChannelFromCache(ce)]);case 19:(x=Ye.sent())&&x._updateParticipantCount(Ee,O)&&U.push(x),Ye.label=20;case 20:return P=N.next(),[3,18];case 21:return[3,24];case 22:return I=Ye.sent(),Ge={error:I},[3,24];case 23:try{P&&!P.done&&(We=N.return)&&We.call(N)}finally{if(Ge)throw Ge.error}return[7];case 24:return U.length>0?[4,this.upsertChannelsToCache(U)]:[3,26];case 25:A=Ye.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=m(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onChannelMemberCountChanged&&r.onChannelMemberCountChanged(A)}catch(e){a={error:e}}finally{try{n&&!n.done&&(i=e.return)&&i.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Ye.label=26;case 26:return[3,56];case 27:return R=e.as(J),L=R.event,X=R.status,ce=R.channelUrl,le=R.channelType,ce&&le===M.OPEN?[4,this.getChannel(ce,!0)]:[3,29];case 28:ie=Ye.sent(),this._dispatcher.dispatch(new b({event:L,source:T.EVENT_POLL_UPDATED})),g(X===H?function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,i;return t(this,(function(t){try{for(e=m(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollDeleted&&r.onPollDeleted(ie,L.pollId)}catch(e){a={error:e}}finally{try{n&&!n.done&&(i=e.return)&&i.call(e)}finally{if(a)throw a.error}}return[2]}))}))}:function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,i;return t(this,(function(t){try{for(e=m(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollUpdated&&r.onPollUpdated(ie,L)}catch(e){a={error:e}}finally{try{n&&!n.done&&(i=e.return)&&i.call(e)}finally{if(a)throw a.error}}return[2]}))}))}),Ye.label=29;case 29:return[3,56];case 30:return se=e.as(V),ue=se.event,ce=se.channelUrl,le=se.channelType,ce&&le===M.OPEN?[4,this.getChannel(ce,!0)]:[3,32];case 31:he=Ye.sent(),this._dispatcher.dispatch(new w({event:ue,source:T.EVENT_POLL_VOTED})),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,i;return t(this,(function(t){try{for(e=m(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollVoted&&r.onPollVoted(he,ue)}catch(e){a={error:e}}finally{try{n&&!n.done&&(i=e.return)&&i.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Ye.label=32;case 32:return[3,56];case 33:if(!(de=e.as(Y).event).isOpenChannelEvent)return[3,55];switch(de.category){case Z.CHANNEL_ENTER:return[3,34];case Z.CHANNEL_EXIT:return[3,36];case Z.CHANNEL_OPERATOR_UPDATE:return[3,38];case Z.USER_CHANNEL_MUTE:case Z.USER_CHANNEL_UNMUTE:return[3,40];case Z.USER_CHANNEL_BAN:case Z.USER_CHANNEL_UNBAN:return[3,42];case Z.CHANNEL_FREEZE:case Z.CHANNEL_UNFREEZE:return[3,44];case Z.CHANNEL_DELETED:return[3,46];case Z.CHANNEL_PROP_CHANGED:return[3,49];case Z.CHANNEL_META_DATA_CHANGED:return[3,51];case Z.CHANNEL_META_COUNTERS_CHANGED:return[3,53]}return[3,55];case 34:return[4,this.getChannel(de.channelUrl,!0)];case 35:return pe=Ye.sent(),fe=e.as(ve),Ee=fe.participantCount,Ce=fe.user,ye=pe._updateParticipantCount(Ee,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&&e.onUserEntered(pe,Ce),ye&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(pe)})),[2]}))}))})),[3,55];case 36:return[4,this.getChannel(de.channelUrl,!0)];case 37:return me=Ye.sent(),Ue=e.as(_e),Ee=Ue.participantCount,ge=Ue.user,we=me._updateParticipantCount(Ee,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&&e.onUserExited(me,ge),we&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(me)})),[2]}))}))})),[3,55];case 38:return[4,this.getChannel(de.channelUrl,!0)];case 39:return Te=Ye.sent(),Me=e.as($).operators,Te.operators=Me,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&&e.onOperatorUpdated(Te,Me)})),[2]}))}))})),[3,55];case 40:return[4,this.getChannel(de.channelUrl,!0)];case 41:return be=Ye.sent(),Ne=de.category===Z.USER_CHANNEL_MUTE,Pe=e.as(Ne?Q:K).user,g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Ne?e.onUserMuted&&e.onUserMuted(be,Pe):e.onUserUnmuted&&e.onUserUnmuted(be,Pe)})),[2]}))}))})),[3,55];case 42:return[4,this.getChannel(de.channelUrl,!0)];case 43:return De=Ye.sent(),He=de.category===Z.USER_CHANNEL_BAN,Oe=e.as(He?q:z).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&&e.onUserBanned(De,Oe):e.onUserUnbanned&&e.onUserUnbanned(De,Oe)})),[2]}))}))})),[3,55];case 44:return[4,this.getChannel(de.channelUrl,!0)];case 45:return xe=Ye.sent(),Ie=e.as(k).freeze,xe.isFrozen=Ie,this.upsertChannelsToCache([xe]),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Ie?e.onChannelFrozen&&e.onChannelFrozen(xe):e.onChannelUnfrozen&&e.onChannelUnfrozen(xe)})),[2]}))}))})),[3,55];case 46:return[4,this.getChannel(de.channelUrl,!0)];case 47:return Ae=Ye.sent(),[4,this.removeChannelsFromCache([Ae.url])];case 48:return Ye.sent(),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Ae.url,Ae.channelType)})),[2]}))}))})),[3,55];case 49:return[4,this.getChannelWithoutCache(de.channelUrl,!0)];case 50:return Re=Ye.sent(),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Re)})),[2]}))}))})),[3,55];case 51:return[4,this.getChannel(de.channelUrl,!0)];case 52:return Le=Ye.sent(),Fe=e.as(S),Se=Fe.created,ke=Fe.updated,qe=Fe.deleted,Se&&Le._upsertCachedMetaData(Se,de.ts),ke&&Le._upsertCachedMetaData(ke,de.ts),qe&&Le._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){Se&&e.onMetaDataCreated&&e.onMetaDataCreated(Le,Se),ke&&e.onMetaDataUpdated&&e.onMetaDataUpdated(Le,ke),qe&&e.onMetaDataDeleted&&e.onMetaDataDeleted(Le,qe)})),[2]}))}))})),[3,55];case 53:return[4,this.getChannel(de.channelUrl,!0)];case 54:return ze=Ye.sent(),Qe=e.as(F),Ke=Qe.created,Ve=Qe.updated,je=Qe.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&&e.onMetaCounterCreated(ze,Ke),Ve&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(ze,Ve),je&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(ze,je)})),[2]}))}))})),[3,55];case 55:return[3,56];case 56:return[3,58];case 57:if(Be=Ye.sent(),E(Be))throw Be;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:N(i("string",e)).throw(P.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,o;return t(this,(function(t){switch(t.label){case 0:return N(i("string",e)).throw(P.invalidParameters),n=new he({channelUrl:e,isInternalCall:r}),[4,this._requestQueue.send(n)];case 1:return a=t.sent(),o=a.as(de).channel,[4,this.upsertChannelsToCache([o])];case 2:return[2,t.sent()[0]]}}))}))},e.prototype.createChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,s,u;return t(this,(function(t){switch(t.label){case 0:return n=D(D({},le),e),N(function(e){return a("string",e.operatorUserIds,!0)&&(i("string",e.coverUrlOrImage,!0)||o(e.coverUrlOrImage,!0))&&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||void 0===e.channelUrl)&&i("boolean",e.isEphemeral,!0)}(n)).throw(P.invalidParameters),r=new pe(n),[4,this._requestQueue.send(r)];case 1:return s=t.sent(),u=s.as(de).channel,this.upsertChannelsToCache([u]),[2,u]}}))}))},e}(),Ue={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0},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=s.GET,t.path="".concat(c,"/").concat(encodeURIComponent(r),"/participants"),t.params={token:a,limit:i},t}return e(t,n),t}(l),ge=function(n){function t(e,t){var r=n.call(this,e,t)||this;r.participants=[];var a=t.next,i=t.participants;return r.token=a,r.participants=i.map((function(n){return new ue(e,n)})),r}return e(t,n),t}(h),we=function(r){function a(e,n,t){return r.call(this,e,n,M.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,o;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(D(D({},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,o=a.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw P.queryInProgress;case 4:return[3,6];case 5:throw P.invalidParameters;case 6:return[2]}}))}))},a}(O),Te=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,l=e.data,h=e.customType,f=e.operatorUserIds;return(t=n.call(this)||this).method=s.PUT,t.path="".concat(c,"/").concat(encodeURIComponent(r)),t.params=d(p({cover_url:i("string",a)?a:null,cover_file:o(a)?a:null,name:u,data:l,custom_type:h,operators:f})),t}return e(t,n),t}(l),Me=function(n){function t(e,t){var r=n.call(this,e,t)||this;return r.channel=new Ne(e,t),r}return e(t,n),t}(h),be=function(n){function t(e){var t=this,r=e.channelUrl;return(t=n.call(this)||this).method=s.DELETE,t.path="".concat(c,"/").concat(encodeURIComponent(r)),t}return e(t,n),t}(l);!function(n){function t(e,t){return n.call(this,e,t)||this}e(t,n)}(h);var Ne=function(r){function s(e,n){var t,a=this;return(a=r.call(this,e,n)||this)._lastParticipantCountUpdated=0,a.participantCount=0,a.operators=[],a.channelType=M.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 v(e,n)})):[],a}return e(s,r),s.payloadify=function(e){return d(p(D(D({},X.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return v.payloadify(e)}))})))},s.prototype.serialize=function(){return I(this)},s.prototype.isOperator=function(e){return e instanceof v?this.isOperator(e.userId):this.operators.some((function(n){return n.userId===e}))},s.prototype._updateParticipantCount=function(e,n){return n>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=n,!0)},s.prototype.createParticipantListQuery=function(e){return new we(this._iid,this.url,e)},s.prototype.refresh=function(){return n(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,me.of(this._iid).getChannelWithoutCache(this.url)];case 1:return[2,e.sent()]}}))}))},s.prototype.enter=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,i,o;return t(this,(function(t){switch(t.label){case 0:return e=x.of(this._iid).requestQueue,n=new fe({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(ve),i=a.participantCount,o=a.ts,this._updateParticipantCount(i,o),me.of(this._iid).setEnteredToCache(this),[2]}}))}))},s.prototype.exit=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,i,o;return t(this,(function(t){switch(t.label){case 0:return e=x.of(this._iid).requestQueue,n=new Ce({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(_e),i=a.participantCount,o=a.ts,this._updateParticipantCount(i,o),me.of(this._iid).setExitedToCache(this),se.of(this._iid).fileMessageQueue.cancel(this),[2]}}))}))},s.prototype.updateChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,s,u,c;return t(this,(function(t){switch(t.label){case 0:return n=D(D({},Ue),e),N(function(e){return a("string",e.operatorUserIds,!0)&&(i("string",e.coverUrlOrImage)||o(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&i("string",e.name,!0)&&i("string",e.data,!0)&&i("string",e.customType,!0)}(n)).throw(P.invalidParameters),r=x.of(this._iid).requestQueue,s=new Te(D({channelUrl:this.url},n)),[4,r.send(s)];case 1:return u=t.sent(),c=u.as(Me).channel,this._update(c),[4,me.of(this._iid).upsertChannelsToCache([c])];case 2:return t.sent(),[2,this]}}))}))},s.prototype.updateChannelWithOperatorUserIds=function(e,r,a,i,o){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return n=D(D({},Ue),{name:e,coverUrlOrImage:r,data:a,operatorUserIds:i,customType:o}),[2,this.updateChannel(n)]}))}))},s.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 be({channelUrl:this.url}),[4,e.send(n)];case 1:return t.sent(),[4,me.of(this._iid).removeChannelsFromCache([this.url])];case 2:return t.sent(),[2]}}))}))},s.prototype.sendUserMessage=function(e){return N(!e.isPinnedMessage).throw(P.notSupportedError),r.prototype.sendUserMessage.call(this,e)},s.prototype.sendFileMessage=function(e){return N(!e.isPinnedMessage).throw(P.notSupportedError),r.prototype.sendFileMessage.call(this,e)},s}(X),Pe=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=A,e.onUserExited=A,e.onChannelParticipantCountChanged=A,e.onPollUpdated=A,e.onPollVoted=A,e.onPollDeleted=A,e}return e(t,n),t}(ie)),De=function(n){function t(e){var t=this,r=e.token,a=e.limit,i=e.nameKeyword,o=e.urlKeyword,u=e.customTypes,l=e.includeFrozen,h=e.includeMetaData;return(t=n.call(this)||this).method=s.GET,t.path=c,t.params=d({token:r,limit:a,name_contains:i,url_contains:o,custom_types:u,show_frozen:l,show_metadata:h}),t}return e(t,n),t}(l),He=function(n){function t(e,t){var r=n.call(this,e,t)||this;r.channels=[];var a=t.next,i=t.channels,o=t.ts;return r.token=a,i&&i.length>0&&(r.channels=i.map((function(n){return new Ne(e,n)}))),r.ts="number"==typeof o?o:null,r}return e(t,n),t}(h),Oe=function(r){function o(e,n){var t,a,i,o,s,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!==(o=n.urlKeyword)&&void 0!==o?o:null,u.customTypes=null!==(s=n.customTypes)&&void 0!==s?s:null,u}return e(o,r),o.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)},o.prototype.next=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,i,o;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 De(p(D(D({},this),{token:this._token}))),[4,e.send(n)]):[3,3]:[3,6];case 1:return r=t.sent(),a=r.as(He),i=a.channels,o=a.token,this._token=o,this._hasNext=!!o,[4,me.of(this._iid).upsertChannelsToCache(i)];case 2:return t.sent(),this._isLoading=!1,[2,i];case 3:return[2,[]];case 4:throw P.queryInProgress;case 5:return[3,7];case 6:throw P.invalidParameters;case 7:return[2]}}))}))},o}(R),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,o=n.requestQueue,s=n.logger,u=n.onlineDetector,c=n.cacheContext;r.prototype.init.call(this,e,{sdkState:t,dispatcher:a,sessionManager:i,requestQueue:o,logger:s,onlineDetector:u,cacheContext:c}),this._manager=new me(e,{sdkState:t,dispatcher:a,requestQueue:o})},a.prototype.createOpenChannelListQuery=function(e){return void 0===e&&(e={}),new Oe(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,o){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return(n=D({},le)).name=e,n.coverUrlOrImage=r,n.data=a,n.operatorUserIds=i,n.customType=o,[2,this._manager.createChannel(n)]}))}))},a}(L);export{Ne as OpenChannel,Pe as OpenChannelHandler,Oe as OpenChannelListQuery,xe as OpenChannelModule,we as ParticipantListQuery}; +import{_ as e,b as n,c as t,a0 as r,m as a,a as i,i as o,A as s,aQ as u,aR as c,f as l,h,e as d,u as p,aa as f,U as v,W as C,x as _,y,K as m,w as U,aD as E,z as g,aE as w,ai as T,Q as M,aG as N,t as b,S as P,g as D,aK as H,am as O,V as x,a3 as I,n as A,B as R,an as L}from"./lib/__bundle-087816c3.js";import{q as F,r as S,t as k,w as q,u as z,x as Q,y as K,P as V,z as j,A as B,C as G,E as W,f as X}from"./lib/__bundle-50274a15.js";import{C as Y,a as Z,O as $,P as J,M as ee,T as ne,R as te,U as re,A as ae,B as ie}from"./lib/__bundle-dddddac5.js";import{m as oe,c as se}from"./lib/__bundle-80fd264e.js";import{P as ue}from"./lib/__bundle-cd6df760.js";import"./lib/__bundle-8f39cad4.js";var ce=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!!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){return n(this,void 0,void 0,(function(){return t(this,(function(n){return[2,this._channels.get(e)]}))}))},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:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0},he=function(n){function t(e){var t=e.channelUrl,r=e.isInternalCall,a=n.call(this)||this;return a.method=s.GET,a.path="".concat(r?u:c,"/").concat(encodeURIComponent(t)),a}return e(t,n),t}(l),de=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),pe=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,l=e.data,h=e.customType,f=e.operatorUserIds,v=e.isEphemeral;return(t=n.call(this)||this).method=s.POST,t.path=c,t.params=d(p({channel_url:r,cover_url:i("string",a)?a:null,cover_file:o(a)?a:null,name:u,data:l,custom_type:h,operators:f,is_ephemeral:v})),t}return e(t,n),t}(l);!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 fe=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}(f),ve=function(n){function t(e,t,r){var a,i,o=this;return o=n.call(this,e,"SYEV",r)||this,r.data&&(o.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,o.user=new v(e,r.data),o.ts=null!==(i=r.data.edge_ts)&&void 0!==i?i:0),o}return e(t,n),t}(Y),Ce=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}(f),_e=function(n){function t(e,t,r){var a,i,o=this;return o=n.call(this,e,"EXIT",r)||this,r.data&&(o.participantCount=null!==(a=r.data.participant_count)&&void 0!==a?a:0,o.user=new v(e,r.data),o.ts=null!==(i=r.data.edge_ts)&&void 0!==i?i:0),o}return e(t,n),t}(Y),ye={},me=function(){function e(e,n){var t=n.sdkState,r=n.dispatcher,a=n.requestQueue,i=this;return ye[e]||(this._iid=e,this._sdkState=t,this._requestQueue=a,this._dispatcher=r,this._openChannelCache=new ce(e),this._openChannelHandlers=new Map,this._dispatcher.on((function(e){var n,t;if(e instanceof C)i._handleEvent(e);else if(e instanceof _&&e.stateType===y.CONNECTED){var r=i._openChannelCache.enteredChannels;try{for(var a=m(r),o=a.next();!o.done;o=a.next()){o.value.enter()}}catch(e){n={error:e}}finally{try{o&&!o.done&&(t=a.return)&&t.call(a)}finally{if(n)throw n.error}}}})),ye[e]=this),ye[e]}return e.of=function(e){return ye[e]},e.prototype.buildOpenChannelFromSerializedData=function(e){var n=U(e);return new be(this._iid,be.payloadify(n))},e.prototype.getChannelFromCache=function(e){var r;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,null!==(r=n.sent())&&void 0!==r?r:null]}}))}))},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,o,s;return t(this,(function(t){switch(t.label){case 0:t.trys.push([0,5,6,7]),n=m(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(),o={error:i},[3,7];case 6:try{r&&!r.done&&(s=n.return)&&s.call(n)}finally{if(o)throw o.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,o,s,u,c,l,h,d,p,f,v,C,_,y,U,b,P,D,O,x,I,A,R,L,X,ie,se,ue,ce,le,he,de,pe,fe,Ce,ye,me,Ue,Ee,ge,we,Te,Me,Ne,be,Pe,De,He,Oe,xe,Ie,Ae,Re,Le,Fe,Se,ke,qe,ze,Qe,Ke,Ve,je,Be,Ge,We,Xe=this;return t(this,(function(Ye){switch(Ye.label){case 0:switch(Ye.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 o=null,"MESG"===e.code?o=e.as(W):"FILE"===e.code?o=e.as(oe):"ADMM"!==e.code&&"BRDM"!=e.code||(o=e.as(ae)),o?(r=o.message,a=o.isMentioned,r.channelType!==M.OPEN?[3,3]:[4,this.getChannel(r.channelUrl,!0)]):[3,3];case 2:i=Ye.sent(),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,o,s,u;return t(this,(function(t){try{for(e=m(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())o=n.value,this._openChannelCache.isEnteredChannel(i.url)&&(o.onMessageReceived&&o.onMessageReceived(i,r),a&&o.onMentionReceived&&o.onMentionReceived(i,r))}catch(e){s={error:e}}finally{try{n&&!n.done&&(u=e.return)&&u.call(e)}finally{if(s)throw s.error}}return[2]}))}))})),Ye.label=3;case 3:return[3,56];case 4:return o=null,"MEDI"===e.code?o=e.as(B):"FEDI"===e.code?o=e.as(G):"AEDI"===e.code&&(o=e.as(re)),o?(s=o.message,u=o.mentionCountChange,s.channelType!==M.OPEN?[3,6]:[4,this.getChannel(s.channelUrl,!0)]):[3,6];case 5:c=Ye.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=m(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(c.url)&&(r.onMessageUpdated&&r.onMessageUpdated(c,s),u>0&&r.onMentionReceived&&r.onMentionReceived(c,s))}catch(e){a={error:e}}finally{try{n&&!n.done&&(i=e.return)&&i.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Ye.label=6;case 6:return[3,56];case 7:return l=e.as(j),ce=l.channelUrl,le=l.channelType,h=l.messageId,le!==M.OPEN?[3,9]:[4,this.getChannel(ce,!0)];case 8:d=Ye.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=m(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(d.url)&&r.onMessageDeleted&&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]}))}))})),Ye.label=9;case 9:return[3,56];case 10:return p=e.as(te),ce=p.channelUrl,le=p.channelType,f=p.event,le!==M.OPEN?[3,12]:[4,this.getChannel(ce,!0)];case 11:v=Ye.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=m(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(v.url)&&r.onReactionUpdated&&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]}))}))})),Ye.label=12;case 12:return[3,56];case 13:return(C=e.as(ne).event).channelType!==M.OPEN?[3,15]:[4,this.getChannel(C.channelUrl,!0)];case 14:_=Ye.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=m(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())r=n.value,this._openChannelCache.isEnteredChannel(_.url)&&r.onThreadInfoUpdated&&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]}))}))})),Ye.label=15;case 15:return[3,56];case 16:y=e.as(ee).openChannelMemberCounts,U=[],Ye.label=17;case 17:Ye.trys.push([17,22,23,24]),b=m(y),P=b.next(),Ye.label=18;case 18:return P.done?[3,21]:(D=P.value,ce=D.channelUrl,Ee=D.participantCount,O=D.updatedAt,[4,this.getChannelFromCache(ce)]);case 19:(x=Ye.sent())&&x._updateParticipantCount(Ee,O)&&U.push(x),Ye.label=20;case 20:return P=b.next(),[3,18];case 21:return[3,24];case 22:return I=Ye.sent(),Ge={error:I},[3,24];case 23:try{P&&!P.done&&(We=b.return)&&We.call(b)}finally{if(Ge)throw Ge.error}return[7];case 24:return U.length>0?[4,this.upsertChannelsToCache(U)]:[3,26];case 25:A=Ye.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=m(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onChannelMemberCountChanged&&r.onChannelMemberCountChanged(A)}catch(e){a={error:e}}finally{try{n&&!n.done&&(i=e.return)&&i.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Ye.label=26;case 26:return[3,56];case 27:return R=e.as(J),L=R.event,X=R.status,ce=R.channelUrl,le=R.channelType,ce&&le===M.OPEN?[4,this.getChannel(ce,!0)]:[3,29];case 28:ie=Ye.sent(),this._dispatcher.dispatch(new N({event:L,source:T.EVENT_POLL_UPDATED})),g(X===H?function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,i;return t(this,(function(t){try{for(e=m(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollDeleted&&r.onPollDeleted(ie,L.pollId)}catch(e){a={error:e}}finally{try{n&&!n.done&&(i=e.return)&&i.call(e)}finally{if(a)throw a.error}}return[2]}))}))}:function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,i;return t(this,(function(t){try{for(e=m(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollUpdated&&r.onPollUpdated(ie,L)}catch(e){a={error:e}}finally{try{n&&!n.done&&(i=e.return)&&i.call(e)}finally{if(a)throw a.error}}return[2]}))}))}),Ye.label=29;case 29:return[3,56];case 30:return se=e.as(V),ue=se.event,ce=se.channelUrl,le=se.channelType,ce&&le===M.OPEN?[4,this.getChannel(ce,!0)]:[3,32];case 31:he=Ye.sent(),this._dispatcher.dispatch(new w({event:ue,source:T.EVENT_POLL_VOTED})),g((function(){return n(Xe,void 0,void 0,(function(){var e,n,r,a,i;return t(this,(function(t){try{for(e=m(this._openChannelHandlers.values()),n=e.next();!n.done;n=e.next())(r=n.value).onPollVoted&&r.onPollVoted(he,ue)}catch(e){a={error:e}}finally{try{n&&!n.done&&(i=e.return)&&i.call(e)}finally{if(a)throw a.error}}return[2]}))}))})),Ye.label=32;case 32:return[3,56];case 33:if(!(de=e.as(Y).event).isOpenChannelEvent)return[3,55];switch(de.category){case Z.CHANNEL_ENTER:return[3,34];case Z.CHANNEL_EXIT:return[3,36];case Z.CHANNEL_OPERATOR_UPDATE:return[3,38];case Z.USER_CHANNEL_MUTE:case Z.USER_CHANNEL_UNMUTE:return[3,40];case Z.USER_CHANNEL_BAN:case Z.USER_CHANNEL_UNBAN:return[3,42];case Z.CHANNEL_FREEZE:case Z.CHANNEL_UNFREEZE:return[3,44];case Z.CHANNEL_DELETED:return[3,46];case Z.CHANNEL_PROP_CHANGED:return[3,49];case Z.CHANNEL_META_DATA_CHANGED:return[3,51];case Z.CHANNEL_META_COUNTERS_CHANGED:return[3,53]}return[3,55];case 34:return[4,this.getChannel(de.channelUrl,!0)];case 35:return pe=Ye.sent(),fe=e.as(ve),Ee=fe.participantCount,Ce=fe.user,ye=pe._updateParticipantCount(Ee,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&&e.onUserEntered(pe,Ce),ye&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(pe)})),[2]}))}))})),[3,55];case 36:return[4,this.getChannel(de.channelUrl,!0)];case 37:return me=Ye.sent(),Ue=e.as(_e),Ee=Ue.participantCount,ge=Ue.user,we=me._updateParticipantCount(Ee,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&&e.onUserExited(me,ge),we&&e.onChannelParticipantCountChanged&&e.onChannelParticipantCountChanged(me)})),[2]}))}))})),[3,55];case 38:return[4,this.getChannel(de.channelUrl,!0)];case 39:return Te=Ye.sent(),Me=e.as($).operators,Te.operators=Me,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&&e.onOperatorUpdated(Te,Me)})),[2]}))}))})),[3,55];case 40:return[4,this.getChannel(de.channelUrl,!0)];case 41:return Ne=Ye.sent(),be=de.category===Z.USER_CHANNEL_MUTE,Pe=e.as(be?Q:K).user,g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){be?e.onUserMuted&&e.onUserMuted(Ne,Pe):e.onUserUnmuted&&e.onUserUnmuted(Ne,Pe)})),[2]}))}))})),[3,55];case 42:return[4,this.getChannel(de.channelUrl,!0)];case 43:return De=Ye.sent(),He=de.category===Z.USER_CHANNEL_BAN,Oe=e.as(He?q:z).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&&e.onUserBanned(De,Oe):e.onUserUnbanned&&e.onUserUnbanned(De,Oe)})),[2]}))}))})),[3,55];case 44:return[4,this.getChannel(de.channelUrl,!0)];case 45:return xe=Ye.sent(),Ie=e.as(k).freeze,xe.isFrozen=Ie,this.upsertChannelsToCache([xe]),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){Ie?e.onChannelFrozen&&e.onChannelFrozen(xe):e.onChannelUnfrozen&&e.onChannelUnfrozen(xe)})),[2]}))}))})),[3,55];case 46:return[4,this.getChannel(de.channelUrl,!0)];case 47:return Ae=Ye.sent(),[4,this.removeChannelsFromCache([Ae.url])];case 48:return Ye.sent(),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelDeleted&&e.onChannelDeleted(Ae.url,Ae.channelType)})),[2]}))}))})),[3,55];case 49:return[4,this.getChannelWithoutCache(de.channelUrl,!0)];case 50:return Re=Ye.sent(),g((function(){return n(Xe,void 0,void 0,(function(){return t(this,(function(e){return this._openChannelHandlers.forEach((function(e){e.onChannelChanged&&e.onChannelChanged(Re)})),[2]}))}))})),[3,55];case 51:return[4,this.getChannel(de.channelUrl,!0)];case 52:return Le=Ye.sent(),Fe=e.as(S),Se=Fe.created,ke=Fe.updated,qe=Fe.deleted,Se&&Le._upsertCachedMetaData(Se,de.ts),ke&&Le._upsertCachedMetaData(ke,de.ts),qe&&Le._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){Se&&e.onMetaDataCreated&&e.onMetaDataCreated(Le,Se),ke&&e.onMetaDataUpdated&&e.onMetaDataUpdated(Le,ke),qe&&e.onMetaDataDeleted&&e.onMetaDataDeleted(Le,qe)})),[2]}))}))})),[3,55];case 53:return[4,this.getChannel(de.channelUrl,!0)];case 54:return ze=Ye.sent(),Qe=e.as(F),Ke=Qe.created,Ve=Qe.updated,je=Qe.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&&e.onMetaCounterCreated(ze,Ke),Ve&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(ze,Ve),je&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(ze,je)})),[2]}))}))})),[3,55];case 55:return[3,56];case 56:return[3,58];case 57:if(Be=Ye.sent(),E(Be))throw Be;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(P.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,o;return t(this,(function(t){switch(t.label){case 0:return b(i("string",e)).throw(P.invalidParameters),n=new he({channelUrl:e,isInternalCall:r}),[4,this._requestQueue.send(n)];case 1:return a=t.sent(),o=a.as(de).channel,[4,this.upsertChannelsToCache([o])];case 2:return[2,t.sent()[0]]}}))}))},e.prototype.createChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,s,u;return t(this,(function(t){switch(t.label){case 0:return n=D(D({},le),e),b(function(e){return a("string",e.operatorUserIds,!0)&&(i("string",e.coverUrlOrImage,!0)||o(e.coverUrlOrImage,!0))&&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||void 0===e.channelUrl)&&i("boolean",e.isEphemeral,!0)}(n)).throw(P.invalidParameters),r=new pe(n),[4,this._requestQueue.send(r)];case 1:return s=t.sent(),u=s.as(de).channel,this.upsertChannelsToCache([u]),[2,u]}}))}))},e}(),Ue={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0},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=s.GET,t.path="".concat(c,"/").concat(encodeURIComponent(r),"/participants"),t.params={token:a,limit:i},t}return e(t,n),t}(l),ge=function(n){function t(e,t){var r=n.call(this,e,t)||this;r.participants=[];var a=t.next,i=t.participants;return r.token=a,r.participants=i.map((function(n){return new ue(e,n)})),r}return e(t,n),t}(h),we=function(r){function a(e,n,t){return r.call(this,e,n,M.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,o;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(D(D({},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,o=a.token,this._token=o,this._hasNext=!!o,this._isLoading=!1,[2,i];case 2:return[2,[]];case 3:throw P.queryInProgress;case 4:return[3,6];case 5:throw P.invalidParameters;case 6:return[2]}}))}))},a}(O),Te=function(n){function t(e){var t=this,r=e.channelUrl,a=e.coverUrlOrImage,u=e.name,l=e.data,h=e.customType,f=e.operatorUserIds;return(t=n.call(this)||this).method=s.PUT,t.path="".concat(c,"/").concat(encodeURIComponent(r)),t.params=d(p({cover_url:i("string",a)?a:null,cover_file:o(a)?a:null,name:u,data:l,custom_type:h,operators:f})),t}return e(t,n),t}(l),Me=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=s.DELETE,t.path="".concat(c,"/").concat(encodeURIComponent(r)),t}return e(t,n),t}(l);!function(n){function t(e,t){return n.call(this,e,t)||this}e(t,n)}(h);var be=function(r){function s(e,n){var t,a=this;return(a=r.call(this,e,n)||this)._lastParticipantCountUpdated=0,a.participantCount=0,a.operators=[],a.channelType=M.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 v(e,n)})):[],a}return e(s,r),s.payloadify=function(e){return d(p(D(D({},X.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return v.payloadify(e)}))})))},s.prototype.serialize=function(){return I(this)},s.prototype.isOperator=function(e){return e instanceof v?this.isOperator(e.userId):this.operators.some((function(n){return n.userId===e}))},s.prototype._updateParticipantCount=function(e,n){return n>this._lastParticipantCountUpdated&&(this.participantCount=e,this._lastParticipantCountUpdated=n,!0)},s.prototype.createParticipantListQuery=function(e){return new we(this._iid,this.url,e)},s.prototype.refresh=function(){return n(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,me.of(this._iid).getChannelWithoutCache(this.url)];case 1:return[2,e.sent()]}}))}))},s.prototype.enter=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,i,o;return t(this,(function(t){switch(t.label){case 0:return e=x.of(this._iid).requestQueue,n=new fe({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(ve),i=a.participantCount,o=a.ts,this._updateParticipantCount(i,o),me.of(this._iid).setEnteredToCache(this),[2]}}))}))},s.prototype.exit=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,i,o;return t(this,(function(t){switch(t.label){case 0:return e=x.of(this._iid).requestQueue,n=new Ce({channelUrl:this.url}),[4,e.send(n)];case 1:return r=t.sent(),a=r.as(_e),i=a.participantCount,o=a.ts,this._updateParticipantCount(i,o),me.of(this._iid).setExitedToCache(this),se.of(this._iid).fileMessageQueue.cancel(this),[2]}}))}))},s.prototype.updateChannel=function(e){return n(this,void 0,void 0,(function(){var n,r,s,u,c;return t(this,(function(t){switch(t.label){case 0:return n=D(D({},Ue),e),b(function(e){return a("string",e.operatorUserIds,!0)&&(i("string",e.coverUrlOrImage)||o(e.coverUrlOrImage)||null===e.coverUrlOrImage)&&i("string",e.name,!0)&&i("string",e.data,!0)&&i("string",e.customType,!0)}(n)).throw(P.invalidParameters),r=x.of(this._iid).requestQueue,s=new Te(D({channelUrl:this.url},n)),[4,r.send(s)];case 1:return u=t.sent(),c=u.as(Me).channel,this._update(c),[4,me.of(this._iid).upsertChannelsToCache([c])];case 2:return t.sent(),[2,this]}}))}))},s.prototype.updateChannelWithOperatorUserIds=function(e,r,a,i,o){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return n=D(D({},Ue),{name:e,coverUrlOrImage:r,data:a,operatorUserIds:i,customType:o}),[2,this.updateChannel(n)]}))}))},s.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,me.of(this._iid).removeChannelsFromCache([this.url])];case 2:return t.sent(),[2]}}))}))},s.prototype.sendUserMessage=function(e){return b(!e.isPinnedMessage).throw(P.notSupportedError),r.prototype.sendUserMessage.call(this,e)},s.prototype.sendFileMessage=function(e){return b(!e.isPinnedMessage).throw(P.notSupportedError),r.prototype.sendFileMessage.call(this,e)},s}(X),Pe=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=A,e.onUserExited=A,e.onChannelParticipantCountChanged=A,e.onPollUpdated=A,e.onPollVoted=A,e.onPollDeleted=A,e}return e(t,n),t}(ie)),De=function(n){function t(e){var t=this,r=e.token,a=e.limit,i=e.nameKeyword,o=e.urlKeyword,u=e.customTypes,l=e.includeFrozen,h=e.includeMetaData;return(t=n.call(this)||this).method=s.GET,t.path=c,t.params=d({token:r,limit:a,name_contains:i,url_contains:o,custom_types:u,show_frozen:l,show_metadata:h}),t}return e(t,n),t}(l),He=function(n){function t(e,t){var r=n.call(this,e,t)||this;r.channels=[];var a=t.next,i=t.channels,o=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 o?o:null,r}return e(t,n),t}(h),Oe=function(r){function o(e,n){var t,a,i,o,s,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!==(o=n.urlKeyword)&&void 0!==o?o:null,u.customTypes=null!==(s=n.customTypes)&&void 0!==s?s:null,u}return e(o,r),o.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)},o.prototype.next=function(){return n(this,void 0,void 0,(function(){var e,n,r,a,i,o;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 De(p(D(D({},this),{token:this._token}))),[4,e.send(n)]):[3,3]:[3,6];case 1:return r=t.sent(),a=r.as(He),i=a.channels,o=a.token,this._token=o,this._hasNext=!!o,[4,me.of(this._iid).upsertChannelsToCache(i)];case 2:return t.sent(),this._isLoading=!1,[2,i];case 3:return[2,[]];case 4:throw P.queryInProgress;case 5:return[3,7];case 6:throw P.invalidParameters;case 7:return[2]}}))}))},o}(R),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,o=n.requestQueue,s=n.logger,u=n.onlineDetector,c=n.cacheContext;r.prototype.init.call(this,e,{sdkState:t,dispatcher:a,sessionManager:i,requestQueue:o,logger:s,onlineDetector:u,cacheContext:c}),this._manager=new me(e,{sdkState:t,dispatcher:a,requestQueue:o})},a.prototype.createOpenChannelListQuery=function(e){return void 0===e&&(e={}),new Oe(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,o){return n(this,void 0,void 0,(function(){var n;return t(this,(function(t){return(n=D({},le)).name=e,n.coverUrlOrImage=r,n.data=a,n.operatorUserIds=i,n.customType=o,[2,this._manager.createChannel(n)]}))}))},a}(L);export{be as OpenChannel,Pe as OpenChannelHandler,Oe as OpenChannelListQuery,xe as OpenChannelModule,we as ParticipantListQuery}; diff --git a/package.json b/package.json index f1b9e68..451dcdb 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "4.9.3", + "version": "4.9.4-rc.1", "description": "Sendbird SDK for JavaScript", "name": "@sendbird/chat", "author": "Sendbird ", @@ -24,30 +24,40 @@ "optional": true } }, - "type": "module", - "main": "index.js", + "main": "cjs/index.js", + "module": "index.js", "types": "index.d.ts", + "type": "module", "react-native": "./index.js", "exports": { - "./package.json": "./package.json", ".": { "types": "./index.d.ts", + "import": "./index.js", + "require": "./cjs/index.js", "default": "./index.js" }, "./message": { "types": "./message.d.ts", + "import": "./message.js", + "require": "./cjs/message.js", "default": "./message.js" }, "./groupChannel": { "types": "./groupChannel.d.ts", + "import": "./groupChannel.js", + "require": "./cjs/groupChannel.js", "default": "./groupChannel.js" }, "./openChannel": { "types": "./openChannel.d.ts", + "import": "./openChannel.js", + "require": "./cjs/openChannel.js", "default": "./openChannel.js" }, "./poll": { "types": "./poll.d.ts", + "import": "./poll.js", + "require": "./cjs/poll.js", "default": "./poll.js" } }, diff --git a/poll.js b/poll.js index fb866d1..be997d4 100644 --- a/poll.js +++ b/poll.js @@ -1 +1 @@ -import{_ as t,b as e,an as r,c as n,g as o,t as s,S as l}from"./lib/__bundle-75942676.js";export{a8 as Poll,ao as PollOption,ap as PollStatus}from"./lib/__bundle-75942676.js";import{b as u,c,v as p,d,e as g,f,g as v}from"./lib/__bundle-ad161b2c.js";export{P as PollListQuery,h as PollUpdateEvent,i as PollVoteEvent,a as PollVoterListQuery}from"./lib/__bundle-ad161b2c.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(p(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({},d),t),s(g(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({},f),t),s(v(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,an as r,c as n,g as o,t as s,S as l}from"./lib/__bundle-087816c3.js";export{a8 as Poll,ao as PollOption,ap as PollStatus}from"./lib/__bundle-087816c3.js";import{b as u,c,v as p,d,e as f,f as g,g as v}from"./lib/__bundle-8f39cad4.js";export{P as PollListQuery,h as PollUpdateEvent,i as PollVoteEvent,a as PollVoterListQuery}from"./lib/__bundle-8f39cad4.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(p(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({},d),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(v(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}; diff --git a/sendbird.min.js b/sendbird.min.js index e1b90a5..0ff5519 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 C(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 x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(C,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),x(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;x(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.3",C=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_COMMAND=700700]="INVALID_COMMAND",e[e.UNKNOWN_ERROR=77e4]="UNKNOWN_ERROR",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 x,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:"invalidCommand",get:function(){return new n({code:E.INVALID_COMMAND,message:"Cannot send invalid command."})}},{key:"unknown",get:function(){return new n({code:E.UNKNOWN_ERROR,message:"Unknown error occurred."})}},{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="object"===n(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;r(this,e),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||t.channel.lastMessage?e.channel.lastMessage.createdAt-t.channel.lastMessage.createdAt:0:e.channel.messageCollectionLastAccessedAt>t.channel.messageCollectionLastAccessedAt?1:-1},this._maxSize=Math.max(a,64),o?(this._clearOrder=i,this._customClearOrderComparator=o):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)}return s(e,[{key:"hasSession",get:function(){return!!this.sessionKey}},{key:"clear",value:function(){this.authToken=void 0,this.sessionKey=void 0}}]),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){var r;return e in this._container||(this._container[e]=new Map),null===(r=this._container[e])||void 0===r||r.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(){var e;for(var t in this._container)null===(e=this._container[t])||void 0===e||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},ce=function e(t){if(null!=t){if("object"===n(t)){if(Array.isArray(t)){var r=_(t);for(var a in r)r[a]=e(r[a]);return r}for(var s in t)null===t[s]&&delete t[s];return t}return 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 le,he="v3",de="/".concat(he,"/users"),fe="/".concat(he,"/storage/file"),pe="/".concat(he,"/group_channels"),ve="/".concat(he,"/sdk/group_channels"),_e="/".concat(he,"/open_channels"),me="/".concat(he,"/sdk/open_channels"),ge="/".concat(he,"/search"),ye="/".concat(he,"/report"),ke="/".concat(he,"/emojis"),be="/".concat(he,"/emoji_categories"),Ee="/".concat(he,"/polls"),we="/".concat(he,"/scheduled_messages"),Ce="/".concat(he,"/sdk/ui_kit/configuration"),xe="/".concat(he,"/sdk/statistics"),Te=function(t){switch(t){case e.ChannelType.GROUP:return pe;case e.ChannelType.OPEN:return _e;default:return null}},Se=function(t){switch(t){case e.ChannelType.GROUP:return"".concat(ye,"/group_channels");case e.ChannelType.OPEN:return"".concat(ye,"/open_channels");default:return null}},Ie=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},Ne=function(e,t,n){var r,a,s,i,o=Ie(null!==(r=e.mentionType)&&void 0!==r?r:null,null!==(a=e.mentionedUserIds)&&void 0!==a?a:[],n),u=Ie(null!==(s=t.mentionType)&&void 0!==s?s:null,null!==(i=t.mentionedUserIds)&&void 0!==i?i:[],n);return!o&&u?1:o&&!u?-1:0},Me=function e(t,r,a){var s,i=r||new FormData;for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o)){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"}(le||(le={}));var Ae,Oe=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])}))?Me(e):JSON.stringify(e)}}]),a}(oe),Ue=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),Re=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),Le=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),De=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"}(Ae||(Ae={}));var Pe=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}(),Fe=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},Ge=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 Re&&a.cancel(e.requestId)})),this._logger=u,this._shouldImportFetchCompat=l}return s(e,[{key:"_userAgentWithExtension",get:function(){var e=this._sdkState.extensions,t=Fe()?"reactnative":"JS",n="//";if(e){var r=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",a=e.sb_uikit?"u".concat(e.sb_uikit):"",s=e["device-os-platform"]?"o".concat(e["device-os-platform"]):"";n="".concat(r,"/").concat(a,"/").concat(s)}return"".concat(t,"/c").concat(C.SDK_VERSION,"/").concat(n)}},{key:"_createHeader",value:function(e,t){var n=this._sdkState,r=n.appId,a=n.appVersion,s=Object.assign(Object.assign({},e.headers),{SendBird:"JS,".concat(C.OS_VERSION,",").concat(C.SDK_VERSION,",").concat(r).concat(a?",".concat(a):""),"SB-User-Agent":encodeURIComponent(this._userAgentWithExtension),"Request-Sent-Timestamp":Date.now().toString()});return t||(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 De(new Pe({type:Ae.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=![le.GET,le.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:void 0),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=null),"undefined"!=typeof AbortController){t.next=15;break}return t.next=15,Promise.resolve().then((function(){return Pv}));case 15:if("function"==typeof fetch){t.next=18;break}return t.next=18,Promise.resolve().then((function(){return a_}));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),t.abrupt("return",new Ue(this._iid,p));case 30:if(!p){t.next=37;break}throw((v=new A(p)).isSessionKeyExpiredError||v.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new Le({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}(),qe=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u=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=null!==(o=s.req_id)&&void 0!==o?o:u,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={};try{a=JSON.parse(t.substring(4))}catch(e){r="NOOP"}finally{return new n(e,r,a)}}}]),n}(oe),He=function(){};function je(e){let t=e.length;for(;--t>=0;)e[t]=0}const ze=256,Ve=286,Be=30,Qe=15,Ke=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]),We=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]),Ye=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]),Je=new Array(576);je(Je);const Xe=new Array(60);je(Xe);const $e=new Array(512);je($e);const et=new Array(256);je(et);const tt=new Array(29);je(tt);const nt=new Array(Be);function rt(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 at,st,it;function ot(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}je(nt);const ut=e=>e<256?$e[e]:$e[256+(e>>>7)],ct=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},lt=(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<{lt(e,n[2*t],n[2*t+1])},dt=(e,t)=>{let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1},ft=(e,t,n)=>{const r=new Array(16);let a,s,i=0;for(a=1;a<=Qe;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]=dt(r[t]++,t))}},pt=e=>{let t;for(t=0;t{e.bi_valid>8?ct(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},_t=(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?ht(e,a,t):(s=et[a],ht(e,s+ze+1,t),i=Ke[s],0!==i&&(a-=tt[s],lt(e,a,i)),r--,s=ut(r),ht(e,s,n),i=We[s],0!==i&&(r-=nt[s],lt(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--)mt(e,n,i);u=s;do{i=e.heap[1],e.heap[1]=e.heap[e.heap_len--],mt(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++,mt(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<=Qe;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),ft(n,c,e.bl_count)},kt=(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{lt(e,0+(r?1:0),3),vt(e),ct(e,n),ct(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var Ct=(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(kt(e,e.dyn_ltree,e.l_desc.max_code),kt(e,e.dyn_dtree,e.d_desc.max_code),yt(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),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?wt(e,t,n,r):4===e.strategy||s===a?(lt(e,2+(r?1:0),3),gt(e,Je,Xe)):(lt(e,4+(r?1:0),3),((e,t,n,r)=>{let a;for(lt(e,t-257,5),lt(e,n-1,5),lt(e,r-4,4),a=0;a{Et||((()=>{let e,t,n,r,a;const s=new Array(16);for(n=0,r=0;r<28;r++)for(tt[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*(et[n]+ze+1)]++,e.dyn_dtree[2*ut(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{lt(e,2,3),ht(e,256,Je),(e=>{16===e.bi_valid?(ct(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 Tt=(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 St=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 It=(e,t,n,r)=>{const a=St,s=r+n;e^=-1;for(let n=r;n>>8^a[255&(e^t[n])];return-1^e},Nt={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"},Mt={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:At,_tr_stored_block:Ot,_tr_flush_block:Ut,_tr_tally:Rt,_tr_align:Lt}=xt,{Z_NO_FLUSH:Dt,Z_PARTIAL_FLUSH:Pt,Z_FULL_FLUSH:Ft,Z_FINISH:Gt,Z_BLOCK:qt,Z_OK:Ht,Z_STREAM_END:jt,Z_STREAM_ERROR:zt,Z_DATA_ERROR:Vt,Z_BUF_ERROR:Bt,Z_DEFAULT_COMPRESSION:Qt,Z_FILTERED:Kt,Z_HUFFMAN_ONLY:Wt,Z_RLE:Yt,Z_FIXED:Zt,Z_DEFAULT_STRATEGY:Jt,Z_UNKNOWN:Xt,Z_DEFLATED:$t}=Mt,en=258,tn=262,nn=42,rn=113,an=666,sn=(e,t)=>(e.msg=Nt[t],t),on=e=>2*e-(e>4?9:0),un=e=>{let t=e.length;for(;--t>=0;)e[t]=0},cn=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 ln=(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))},dn=(e,t)=>{Ut(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,hn(e.strm)},fn=(e,t)=>{e.pending_buf[e.pending++]=t},pn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},vn=(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=Tt(e.adler,t,a,n):2===e.state.wrap&&(e.adler=It(e.adler,t,a,n)),e.next_in+=a,e.total_in+=a,a)},_n=(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-tn?e.strstart-(e.w_size-tn):0,c=e.window,l=e.w_mask,h=e.prev,d=e.strstart+en;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},mn=e=>{const t=e.w_size;let n,r,a;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-tn)&&(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),cn(e),r+=t),0===e.strm.avail_in)break;if(n=vn(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=ln(e,e.ins_h,e.window[a+1]);e.insert&&(e.ins_h=ln(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,hn(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&&(vn(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&&(vn(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===Gt)&&t!==Dt&&0===e.strm.avail_in&&r<=a)&&(n=r>a?a:r,i=t===Gt&&0===e.strm.avail_in&&n===r?1:0,Ot(e,e.block_start,n,i),e.block_start+=n,hn(e.strm)),i?3:1)},yn=(e,t)=>{let n,r;for(;;){if(e.lookahead=3&&(e.ins_h=ln(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-tn&&(e.match_length=_n(e,n)),e.match_length>=3)if(r=Rt(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=ln(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=ln(e,e.ins_h,e.window[e.strstart+1]);else r=Rt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(dn(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Gt?(dn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(dn(e,!1),0===e.strm.avail_out)?1:2},kn=(e,t)=>{let n,r,a;for(;;){if(e.lookahead=3&&(e.ins_h=ln(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=Rt(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=ln(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&&(dn(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=Rt(e,0,e.window[e.strstart-1]),r&&dn(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=Rt(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Gt?(dn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(dn(e,!1),0===e.strm.avail_out)?1:2};function bn(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 En=[new bn(0,0,0,0,gn),new bn(4,4,8,4,yn),new bn(4,5,16,8,yn),new bn(4,6,32,32,yn),new bn(4,4,16,16,kn),new bn(8,16,32,32,kn),new bn(8,16,128,128,kn),new bn(8,32,128,256,kn),new bn(32,128,258,1024,kn),new bn(32,258,258,4096,kn)];function wn(){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=$t,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),un(this.dyn_ltree),un(this.dyn_dtree),un(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),un(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),un(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 Cn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==nn&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==rn&&t.status!==an?1:0},xn=e=>{if(Cn(e))return sn(e,zt);e.total_in=e.total_out=0,e.data_type=Xt;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?nn:rn,e.adler=2===t.wrap?0:1,t.last_flush=-2,At(t),Ht},Tn=e=>{const t=xn(e);var n;return t===Ht&&((n=e.state).window_size=2*n.w_size,un(n.head),n.max_lazy_match=En[n.level].max_lazy,n.good_match=En[n.level].good_length,n.nice_match=En[n.level].nice_length,n.max_chain_length=En[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},Sn=(e,t,n,r,a,s)=>{if(!e)return zt;let i=1;if(t===Qt&&(t=6),r<0?(i=0,r=-r):r>15&&(i=2,r-=16),a<1||a>9||n!==$t||r<8||r>15||t<0||t>9||s<0||s>Zt||8===r&&1!==i)return sn(e,zt);8===r&&(r=9);const o=new wn;return e.state=o,o.strm=e,o.status=nn,o.wrap=i,o.gzhead=null,o.w_bits=r,o.w_size=1<Sn(e,t,$t,15,8,Jt),deflateInit2:Sn,deflateReset:Tn,deflateResetKeep:xn,deflateSetHeader:(e,t)=>Cn(e)||2!==e.state.wrap?zt:(e.state.gzhead=t,Ht),deflate:(e,t)=>{if(Cn(e)||t>qt||t<0)return e?sn(e,zt):zt;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===an&&t!==Gt)return sn(e,0===e.avail_out?Bt:zt);const r=n.last_flush;if(n.last_flush=t,0!==n.pending){if(hn(e),0===e.avail_out)return n.last_flush=-1,Ht}else if(0===e.avail_in&&on(t)<=on(r)&&t!==Gt)return sn(e,Bt);if(n.status===an&&0!==e.avail_in)return sn(e,Bt);if(n.status===nn&&0===n.wrap&&(n.status=rn),n.status===nn){let t=$t+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=Wt||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,pn(n,t),0!==n.strstart&&(pn(n,e.adler>>>16),pn(n,65535&e.adler)),e.adler=1,n.status=rn,hn(e),0!==n.pending)return n.last_flush=-1,Ht}if(57===n.status)if(e.adler=0,fn(n,31),fn(n,139),fn(n,8),n.gzhead)fn(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)),fn(n,255&n.gzhead.time),fn(n,n.gzhead.time>>8&255),fn(n,n.gzhead.time>>16&255),fn(n,n.gzhead.time>>24&255),fn(n,9===n.level?2:n.strategy>=Wt||n.level<2?4:0),fn(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(fn(n,255&n.gzhead.extra.length),fn(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=It(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(fn(n,0),fn(n,0),fn(n,0),fn(n,0),fn(n,0),fn(n,9===n.level?2:n.strategy>=Wt||n.level<2?4:0),fn(n,3),n.status=rn,hn(e),0!==n.pending)return n.last_flush=-1,Ht;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=It(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=a,hn(e),0!==n.pending)return n.last_flush=-1,Ht;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=It(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=It(e.adler,n.pending_buf,n.pending-r,r)),hn(e),0!==n.pending)return n.last_flush=-1,Ht;r=0}t=n.gzindexr&&(e.adler=It(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=It(e.adler,n.pending_buf,n.pending-r,r)),hn(e),0!==n.pending)return n.last_flush=-1,Ht;r=0}t=n.gzindexr&&(e.adler=It(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&&(hn(e),0!==n.pending))return n.last_flush=-1,Ht;fn(n,255&e.adler),fn(n,e.adler>>8&255),e.adler=0}if(n.status=rn,hn(e),0!==n.pending)return n.last_flush=-1,Ht}if(0!==e.avail_in||0!==n.lookahead||t!==Dt&&n.status!==an){let r=0===n.level?gn(n,t):n.strategy===Wt?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(mn(e),0===e.lookahead)){if(t===Dt)return 1;break}if(e.match_length=0,n=Rt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(dn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Gt?(dn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(dn(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===Yt?((e,t)=>{let n,r,a,s;const i=e.window;for(;;){if(e.lookahead<=en){if(mn(e),e.lookahead<=en&&t===Dt)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+en;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=Rt(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=Rt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(dn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Gt?(dn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(dn(e,!1),0===e.strm.avail_out)?1:2})(n,t):En[n.level].func(n,t);if(3!==r&&4!==r||(n.status=an),1===r||3===r)return 0===e.avail_out&&(n.last_flush=-1),Ht;if(2===r&&(t===Pt?Lt(n):t!==qt&&(Ot(n,0,0,!1),t===Ft&&(un(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),hn(e),0===e.avail_out))return n.last_flush=-1,Ht}return t!==Gt?Ht:n.wrap<=0?jt:(2===n.wrap?(fn(n,255&e.adler),fn(n,e.adler>>8&255),fn(n,e.adler>>16&255),fn(n,e.adler>>24&255),fn(n,255&e.total_in),fn(n,e.total_in>>8&255),fn(n,e.total_in>>16&255),fn(n,e.total_in>>24&255)):(pn(n,e.adler>>>16),pn(n,65535&e.adler)),hn(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?Ht:jt)},deflateEnd:e=>{if(Cn(e))return zt;const t=e.state.status;return e.state=null,t===rn?sn(e,Vt):Ht},deflateSetDictionary:(e,t)=>{let n=t.length;if(Cn(e))return zt;const r=e.state,a=r.wrap;if(2===a||1===a&&r.status!==nn||r.lookahead)return zt;if(1===a&&(e.adler=Tt(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){0===a&&(un(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,mn(r);r.lookahead>=3;){let e=r.strstart,t=r.lookahead-2;do{r.ins_h=ln(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,mn(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,Ht},deflateInfo:"pako deflate (from Nodeca project)"};const Nn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Mn={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)Nn(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;On[254]=On[254]=1;var Un={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&&An)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+On[e[n]]>t?n:t}};var Rn=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 Ln=Object.prototype.toString,{Z_NO_FLUSH:Dn,Z_SYNC_FLUSH:Pn,Z_FULL_FLUSH:Fn,Z_FINISH:Gn,Z_OK:qn,Z_STREAM_END:Hn,Z_DEFAULT_COMPRESSION:jn,Z_DEFAULT_STRATEGY:zn,Z_DEFLATED:Vn}=Mt;function Bn(e){this.options=Mn.assign({level:jn,method:Vn,chunkSize:16384,windowBits:15,memLevel:8,strategy:zn},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 Rn,this.strm.avail_out=0;let n=In.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==qn)throw new Error(Nt[n]);if(t.header&&In.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?Un.string2buf(t.dictionary):"[object ArrayBuffer]"===Ln.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=In.deflateSetDictionary(this.strm,e),n!==qn)throw new Error(Nt[n]);this._dict_set=!0}}function Qn(e,t){const n=new Bn(t);if(n.push(e,!0),n.err)throw n.msg||Nt[n.err];return n.result}Bn.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?Gn:Dn,"string"==typeof e?n.input=Un.string2buf(e):"[object ArrayBuffer]"===Ln.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===Pn||s===Fn)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(a=In.deflate(n,s),a===Hn)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),a=In.deflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===qn;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},Bn.prototype.onData=function(e){this.chunks.push(e)},Bn.prototype.onEnd=function(e){e===qn&&(this.result=Mn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Kn={Deflate:Bn,deflate:Qn,deflateRaw:function(e,t){return(t=t||{}).raw=!0,Qn(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,Qn(e,t)},constants:Mt};const Wn=16209;var Yn=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,C,x;const T=e.state;n=e.next_in,C=e.input,r=n+(e.avail_in-5),a=e.next_out,x=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)x[a++]=65535&g;else{if(!(16&y)){if(0==(64&y)){g=p[(65535&g)+(d&(1<>>=y,f-=y),f<15&&(d+=C[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=Wn;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=Wn;break e}if(E=0,w=h,0===l){if(E+=u-y,y2;)x[a++]=w[E++],x[a++]=w[E++],x[a++]=w[E++],k-=3;k&&(x[a++]=w[E++],k>1&&(x[a++]=w[E++]))}else{E=a-b;do{x[a++]=x[E++],x[a++]=x[E++],x[a++]=x[E++],k-=3}while(k>2);k&&(x[a++]=x[E++],k>1&&(x[a++]=x[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,C=0,x=null;const T=new Uint16Array(16),S=new Uint16Array(16);let I,N,M,A=null;for(v=0;v<=Zn;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=x[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?(C&=c-1,C+=c):C=0,_++,0==--T[v]){if(v===g)break;v=t[n+i[_]]}if(v>y&&(C&d)!==h){for(0===b&&(b=y),f+=m,k=v-b,E=1<852||2===e&&w>592)return 1;h=C&d,a[h]=y<<24|k<<16|f-s|0}}return 0!==C&&(a[f+C]=v-b<<24|64<<16|0),o.bits=y,0};const{Z_FINISH:nr,Z_BLOCK:rr,Z_TREES:ar,Z_OK:sr,Z_STREAM_END:ir,Z_NEED_DICT:or,Z_STREAM_ERROR:ur,Z_DATA_ERROR:cr,Z_MEM_ERROR:lr,Z_BUF_ERROR:hr,Z_DEFLATED:dr}=Mt,fr=16180,pr=16190,vr=16191,_r=16192,mr=16194,gr=16199,yr=16200,kr=16206,br=16209,Er=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function wr(){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 Cr=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},xr=e=>{if(Cr(e))return ur;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=fr,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,sr},Tr=e=>{if(Cr(e))return ur;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,xr(e)},Sr=(e,t)=>{let n;if(Cr(e))return ur;const r=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?ur:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,Tr(e))},Ir=(e,t)=>{if(!e)return ur;const n=new wr;e.state=n,n.strm=e,n.window=null,n.mode=fr;const r=Sr(e,t);return r!==sr&&(e.state=null),r};let Nr,Mr,Ar=!0;const Or=e=>{if(Ar){Nr=new Int32Array(512),Mr=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(tr(1,e.lens,0,288,Nr,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;tr(2,e.lens,0,32,Mr,0,e.work,{bits:5}),Ar=!1}e.lencode=Nr,e.lenbits=9,e.distcode=Mr,e.distbits=5},Ur=(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.whaveIr(e,15),inflateInit2:Ir,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,C=0;const x=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(Cr(e)||!e.output||!e.input&&0!==e.avail_in)return ur;n=e.state,n.mode===vr&&(n.mode=_r),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=sr;e:for(;;)switch(n.mode){case fr:if(0===n.wrap){n.mode=_r;break}for(;l<16;){if(0===o)break e;o--,c+=r[s++]<>>8&255,n.check=It(n.check,x,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=br;break}if((15&c)!==dr){e.msg="unknown compression method",n.mode=br;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=br;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(x[0]=255&c,x[1]=c>>>8&255,n.check=It(n.check,x,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,x[2]=c>>>16&255,x[3]=c>>>24&255,n.check=It(n.check,x,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&&(x[0]=255&c,x[1]=c>>>8&255,n.check=It(n.check,x,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=It(n.check,x,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=It(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=vr;break;case 16189:for(;l<32;){if(0===o)break e;o--,c+=r[s++]<>>=7&l,l-=7&l,n.mode=kr;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(Or(n),n.mode=gr,t===ar){c>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=br}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=br;break}if(n.length=65535&c,c=0,l=0,n.mode=mr,t===ar)break e;case mr: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=vr;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=br;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=tr(0,n.lens,0,19,n.lencode,0,n.work,T),n.lenbits=T.bits,w){e.msg="invalid code lengths set",n.mode=br;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>24,m=C>>>16&255,g=65535&C,!(_<=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=br;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=br;break}for(;f--;)n.lens[n.have++]=E}}if(n.mode===br)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=br;break}if(n.lenbits=9,T={bits:n.lenbits},w=tr(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=br;break}if(n.distbits=6,n.distcode=n.distdyn,T={bits:n.distbits},w=tr(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=br;break}if(n.mode=gr,t===ar)break e;case gr:n.mode=yr;case yr: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,Yn(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===vr&&(n.back=-1);break}for(n.back=0;C=n.lencode[c&(1<>>24,m=C>>>16&255,g=65535&C,!(_<=l);){if(0===o)break e;o--,c+=r[s++]<>y)],_=C>>>24,m=C>>>16&255,g=65535&C,!(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=vr;break}if(64&m){e.msg="invalid literal/length code",n.mode=br;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(;C=n.distcode[c&(1<>>24,m=C>>>16&255,g=65535&C,!(_<=l);){if(0===o)break e;o--,c+=r[s++]<>y)],_=C>>>24,m=C>>>16&255,g=65535&C,!(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=br;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=br;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=br;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=yr);break;case 16205:if(0===u)break e;a[i++]=n.length,u--,n.mode=yr;break;case kr:if(n.wrap){for(;l<32;){if(0===o)break e;o--,c|=r[s++]<{if(Cr(e))return ur;let t=e.state;return t.window&&(t.window=null),e.state=null,sr},inflateGetHeader:(e,t)=>{if(Cr(e))return ur;const n=e.state;return 0==(2&n.wrap)?ur:(n.head=t,t.done=!1,sr)},inflateSetDictionary:(e,t)=>{const n=t.length;let r,a,s;return Cr(e)?ur:(r=e.state,0!==r.wrap&&r.mode!==pr?ur:r.mode===pr&&(a=1,a=Tt(a,t,n,0),a!==r.check)?cr:(s=Ur(e,t,n,n),s?(r.mode=16210,lr):(r.havedict=1,sr)))},inflateInfo:"pako inflate (from Nodeca project)"};var Lr=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 Dr=Object.prototype.toString,{Z_NO_FLUSH:Pr,Z_FINISH:Fr,Z_OK:Gr,Z_STREAM_END:qr,Z_NEED_DICT:Hr,Z_STREAM_ERROR:jr,Z_DATA_ERROR:zr,Z_MEM_ERROR:Vr}=Mt;function Br(e){this.options=Mn.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 Rn,this.strm.avail_out=0;let n=Rr.inflateInit2(this.strm,t.windowBits);if(n!==Gr)throw new Error(Nt[n]);if(this.header=new Lr,Rr.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Un.string2buf(t.dictionary):"[object ArrayBuffer]"===Dr.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=Rr.inflateSetDictionary(this.strm,t.dictionary),n!==Gr)))throw new Error(Nt[n])}function Qr(e,t){const n=new Br(t);if(n.push(e),n.err)throw n.msg||Nt[n.err];return n.result}Br.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?Fr:Pr,"[object ArrayBuffer]"===Dr.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=Rr.inflate(n,i),s===Hr&&a&&(s=Rr.inflateSetDictionary(n,a),s===Gr?s=Rr.inflate(n,i):s===zr&&(s=Hr));n.avail_in>0&&s===qr&&n.state.wrap>0&&0!==e[n.next_in];)Rr.inflateReset(n),s=Rr.inflate(n,i);switch(s){case jr:case zr:case Hr:case Vr:return this.onEnd(s),this.ended=!0,!1}if(o=n.avail_out,n.next_out&&(0===n.avail_out||s===qr))if("string"===this.options.to){let e=Un.utf8border(n.output,n.next_out),t=n.next_out-e,a=Un.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!==Gr||0!==o){if(s===qr)return s=Rr.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},Br.prototype.onData=function(e){this.chunks.push(e)},Br.prototype.onEnd=function(e){e===Gr&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Mn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Kr={Inflate:Br,inflate:Qr,inflateRaw:function(e,t){return(t=t||{}).raw=!0,Qr(e,t)},ungzip:Qr,constants:Mt};const{Deflate:Wr,deflate:Yr,deflateRaw:Zr,gzip:Jr}=Kn,{Inflate:Xr,inflate:$r,inflateRaw:ea,ungzip:ta}=Kr;var na,ra={Deflate:Wr,deflate:Yr,deflateRaw:Zr,gzip:Jr,Inflate:Xr,inflate:$r,inflateRaw:ea,ungzip:ta,constants:Mt},aa=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=ra.ungzip(e),t.abrupt("return",String.fromCharCode.apply(null,r));case 2:case"end":return t.stop()}}),n)})))};e.ConnectionState=void 0,(na=e.ConnectionState||(e.ConnectionState={})).CONNECTING="CONNECTING",na.OPEN="OPEN",na.CLOSED="CLOSED";var sa,ia=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=qe.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 Le(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,aa(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=He,t._ws.onmessage=He,t._ws.onerror=He,t._ws.onclose=function(){t.dispatch("close"),n()},t._ws.close(),t._ws=void 0):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),oa=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?{}: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),ua=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),ca=s((function e(){var t=this;r(this,e),this.promise=new Promise((function(e,n){t.resolve=e,t.reject=n}))})),la=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 Ge(t,{auth:s,sdkState:i,dispatcher:o,logger:u,useFetchCompat:l}),this.websocketClient=new ia(t,{sdkState:i,dispatcher:o,logger:u}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&a._dispatcher.dispatch(new ua(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(this._sdkState.websocket){t.next=2;break}throw A.connectionRequired;case 2:if(r=new ca,e.ackRequired){s=function(t,n){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(void 0,e)},reject:function(e){return s(e)}}),this.websocketClient.send(e)}catch(e){s(e)}}else try{this.websocketClient.send(e),r.resolve()}catch(e){r.reject(e)}return t.abrupt("return",r.promise);case 5: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 Oe)){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 oa)){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"}(sa||(sa={}));var ha,da=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),fa=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=sa.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new la(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 da){var n=e.stateType;switch(s._currentConnectionStateType=n,n){case sa.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 sa.INITIALIZED:case sa.INTERNAL_DISCONNECTED:case sa.EXTERNAL_DISCONNECTED:case sa.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===sa.CONNECTED}},{key:"isLazyCallActivated",get:function(){return this._currentConnectionStateType===sa.CONNECTING||this._currentConnectionStateType===sa.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 oa)){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 ca,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:case 37:t.next=40;break;case 19:if(!(e instanceof Oe)){t.next=39;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 ca,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 39:throw A.invalidCommand;case 40: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}(),pa="sendbird@devicetokens",va=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 ue(ce({type:e.type,token:e.token}))}}]),e}(),_a=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(de,"/").concat(s,"/session_key"),a.method=le.POST,a.params={token:i,expiring_session:!!u},a.requireAuth=!1,a}return s(n)}(Oe),ma=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?"":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)}(oa),ga=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)}(Ue),ya=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o;return r(this,n),(i=t.call(this,e,"LOGI",s)).error=null,i.newKey=null,i.newKey=null!==(o=s.new_key)&&void 0!==o?o:null,i.error=s.error?new A(s.error):null,i}return s(n)}(qe),ka=function(e){i(n,e);var t=f(n);function n(){return r(this,n),t.apply(this,arguments)}return s(n)}(oe),ba=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)})))},Ea=function(){function e(){r(this,e)}return s(e,[{key:"calcTimeout",value:function(){return 0}}]),e}(),wa=function(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Ea;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(e){return i=null!=e?e:new Error("Halted")},u=function(){s=0};case 4:if(!(-1===n||s=0}},{key:"createRefreshWebsocketCommand",value:function(e,t){return new ma({authToken:e,expiringSession:!0,requestId:t})}},{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(ya),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 _a({userId:this._sdkState.userId,authToken:e,expiringSession:!0}),n.next=3,wa((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(ga),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(){var a,s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._currentConnectionStateType!==sa.CONNECTED){t.next=26;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=26;break}if(!n){t.next=26;break}return t.next=14,this._receiveNewAuthToken();case 14:if(!(a=t.sent)){t.next=22;break}return this.auth.authToken=a,t.next=19,this._refreshSessionKey(this.auth.authToken,!1);case 19:this.complete(),t.next=25;break;case 22:return t.next=24,this.clear();case 24:this.close();case 25:return t.abrupt("return");case 26:return t.prev=26,t.next=29,this._refreshSessionKeyByApi(e);case 29:this.complete(),t.next=55;break;case 32:if(t.prev=32,t.t1=t.catch(26),!this._isSessionRelatedError(t.t1)){t.next=54;break}if(!n){t.next=51;break}return t.next=38,this._receiveNewAuthToken();case 38:if(!(s=t.sent)){t.next=46;break}return this.auth.authToken=s,t.next=43,this._refreshSessionKeyByApi(this.auth.authToken);case 43:this.complete(),t.next=49;break;case 46:return t.next=48,this.clear();case 48:this.close();case 49:t.next=52;break;case 51:throw t.t1;case 52:t.next=55;break;case 54:throw t.t1;case 55:case"end":return t.stop()}}),r,this,[[1,8],[26,32]])})))}},{key:"_receiveNewAuthToken",value:function(){var e=this,n=new ca;return Ca((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,Ta.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(pa);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(pa,{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(),Ta.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,e.next=8,this.saveDeviceToken();case 8:case"end":return e.stop()}}),e,this)})))}}]),a}(se),Ia=function(){function e(){r(this,e),this.type=sa.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}(),Na=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=sa.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 La,r);case 6:Ca((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&&e.onDisconnected(a)}));case 1:case"end":return t.stop()}}),n)})))}));case 7:case"end":return n.stop()}}),n)})))}}]),a}(Ia),Ma=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.call(this)).type=sa.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 Ra({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 Oa,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 Na,r);case 3:case"end":return t.stop()}}),n)})))}}]),a}(Ia),Aa=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=sa.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 Oa,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 Ra({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 Oa,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 Ma,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 Na,r);case 3:case"end":return t.stop()}}),n)})))}}]),a}(Ia),Oa=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=sa.RECONNECTING,e.name="reconnecting",e._callbacks=[],e}return s(a,[{key:"_halt",value:function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=void 0)}},{key:"_flushCallbacks",value:function(e){this._haltConnect=void 0,this._resetConnect=void 0,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 ca,this._callbacks.push((function(e){return e?a.reject(e):a.resolve()})),Ca((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&&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,wa((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 Ua,r);case 10:Ca((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(),e.connectionHandlers.forEach((function(e){e.onReconnectSucceeded&&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 Aa({autoReconnect:!1}),r);case 20:Ca((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&&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 ca,this._halt(A.connectionCanceled),e.cancelConnectForRetry(),this._callbacks.push((function(){var t=Date.now();e.changeState(new Ra({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 ca,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 Aa({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 Ma,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 Na,r);case 4:case"end":return t.stop()}}),n,this)})))}}]),a}(Ia),Ua=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=sa.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 Oa,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 Aa({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 Ma,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 Na,r);case 3:case"end":return t.stop()}}),n)})))}}]),a}(Ia),Ra=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=sa.CONNECTING,t.name="connecting",t._authToken="",t._callbacks=[],t._authToken=s,t}return s(a,[{key:"_halt",value:function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=void 0)}},{key:"_flushCallbacks",value:function(e){this._haltConnect=void 0,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 ca,this._callbacks.push((function(e){return e?a.reject(e):a.resolve()})),n.prev=3,n.next=6,wa((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 Ua,r);case 8:Ca((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(),e.connectionHandlers.forEach((function(t){t.onConnected&&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 La,r);case 20:Ca((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 ca,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,i=void 0!==s&&s;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 Aa({autoReconnect:i}),r);case 5:t.next=9;break;case 7:return t.next=9,e.changeState(new Na,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 Ma,r);case 5:t.next=9;break;case 7:return t.next=9,e.changeState(new Na,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 Na,r);case 4:case"end":return t.stop()}}),n,this)})))}}]),a}(Ia),La=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=sa.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 Ra({authToken:n}),a);case 3:case"end":return t.stop()}}),r)})))}}]),a}(Ia),Da=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)}(oa),Pa=function(){function e(t){var n=t.pingDelegate,a=t.sdkState,s=t.logger;r(this,e),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;if(!this.sdkState.websocket)throw A.connectionRequired;var n=new Da;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()}),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=void 0),this.pingDelegate.error()}return n}},{key:"pong",value:function(){this._logger.debug("pinger.pong()"),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)}},{key:"refreshTimer",value:function(){var e,t=this;if(!this.sdkState.websocket)throw A.connectionRequired;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=void 0),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)}}]),e}(),Fa=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(ce({last_updated_at:e.lastUpdatedAt}))}}]),e}(),Ga=1048576,qa=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*Ga: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 Fa(null!==(i=o.uikit_config)&&void 0!==i?i:{})}return s(e,null,[{key:"payloadify",value:function(e){return ue(ce({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/Ga,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,uikit_config:e.uikitConfigInfo?Fa.payloadify(e.uikitConfigInfo):null}))}}]),e}(),Ha=function(){function e(t){r(this,e),this._iid="",this._iid=t}return s(e,null,[{key:"payloadify",value:function(e){return{}}}]),e}(),ja=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=le.POST,a.path="".concat(de,"/").concat(s,"/metadata"),a.params={metadata:i},a}return s(n)}(Oe),za=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)}(Ue),Va=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=le.PUT,a.path="".concat(de,"/").concat(s,"/metadata"),a.params={metadata:i,upsert:o},a}return s(n)}(Oe),Ba=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)}(Ue),Qa=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=le.DELETE,a.path="".concat(de,"/").concat(s,"/metadata/").concat(i),a}return s(n)}(Oe),Ka=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=le.DELETE,a.path="".concat(de,"/").concat(s,"/metadata"),a}return s(n)}(Oe),Wa=function(e,t){var n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},Ya=function(e,t){var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},Za=function(e){return{do:function(t){e||t()},throw:function(t){if(!e)throw t}}};e.UserOnlineState=void 0,(ha=e.UserOnlineState||(e.UserOnlineState={})).ONLINE="online",ha.OFFLINE="offline",ha.NON_AVAILABLE="nonavailable";var Ja,Xa=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=fs.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl}},{key:"serialize",value:function(){return Wa(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 Za(this._isValidMetaData(e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new ja({userId:a.userId,metadata:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(za),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 Za(this._isValidMetaData(e)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Va({userId:s.userId,metadata:e,upsert:n}),t.next=5,i.send(o);case 5:return u=t.sent,c=u.as(Ba),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 Za(L("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Qa({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=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Ka({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 ue(ce(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})))}}]),u}(Ha),$a=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),es=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 qa(n),this.user=new Xa(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=fs.of(this._iid);r.sdkState.websocket&&(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 $a({userProfile:this}))}}],[{key:"payloadify",value:function(e){return ue(ce(Object.assign(Object.assign(Object.assign({},Xa.payloadify(e.user)),qa.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}(),ts=function(e){i(a,e);var n=f(a);function a(e,t,s){var i,o,u,c;return r(this,a),(i=n.call(this,e,t,s)).error=null,i.userProfile=new es(e,s),i.deviceTokenLastDeletedAt=null!==(o=s.device_token_last_deleted_at)&&void 0!==o?o:0,i.key=null!==(u=s.key)&&void 0!==u?u:"",i.ekey=null!==(c=s.ekey)&&void 0!==c?c:"",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=fs.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("","LOGI",Object.assign({user_id:"",error:!0},e))}}]),a}(qe),ns=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),rs=function(e){i(a,e);var n=f(a);function a(e,t){var s,i,o=t.sdkState,u=t.cacheContext,c=t.connectionHandlers,l=t.sessionManager,h=t.websocketClient,d=t.dispatcher,f=t.logger,p=t.entryState,v=void 0===p?new La:p;return r(this,a),(s=n.call(this))._stateUpdatedAt=0,s._connectingAt=0,s._connectionRequestQueue=[],s._iid=e,s.sdkState=o,s.cacheContext=u,s.connectionHandlers=c,s._sessionManager=l,s._websocketClient=h,s._dispatcher=d,s._logger=f,s._currentState=v,(null===(i=s.sdkState.websocket)||void 0===i?void 0:i.pingerDisabled)||(s._pinger=new Pa({pingDelegate:{send:function(e){return s._websocketClient.send(e)},error:function(e){return s._websocketClient.error(e)}},sdkState:s.sdkState,logger:f})),s._websocketClient.on("open",(function(){s._tryResolveConnectionRequest()})).on("message",(function(e){if("LOGI"===e.code)s.clearLoginTimer(),s._dispatcher.dispatch(e.as(ts))})).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=void 0,s._unresolvedLogi||s._rejectConnectionRequest(A.networkError)}),500)})),s._dispatcher.on((function(e){e instanceof ts&&(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 da({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=void 0,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===(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=void 0,(r.error.isSessionKeyExpiredError||r.error.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new Le({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,n,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",a=this.sdkState,s=a.appId,i=a.appVersion,o=a.userId;a.extensions;var u=this.cacheContext.localCacheEnabled,c=this._sessionManager.auth,l=null===(e=this.sdkState.websocket)||void 0===e?void 0:e.compression,h=null!==(t=this.sdkState.extensions)&&void 0!==t?t:{},d=!!h.sb_uikit,f=h.sb_syncmanager?"s".concat(h.sb_syncmanager):"",p=h.sb_uikit?"u".concat(h.sb_uikit):"",v="JS/c".concat(C.SDK_VERSION,"/").concat(f,"/").concat(p);return"".concat(null===(n=this.sdkState.websocket)||void 0===n?void 0:n.host,"/?p=JS&pv=").concat(encodeURIComponent(C.OS_VERSION),"&sv=").concat(encodeURIComponent(C.SDK_VERSION),"&ai=").concat(s).concat(i?"&av=".concat(i):"").concat(c.hasSession?"&key=".concat(encodeURIComponent(c.sessionKey)):"&user_id=".concat(encodeURIComponent(o),"&access_token=").concat(encodeURIComponent(r)),"&pmce=").concat(l?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(v,"&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(u?1:0,"&include_poll_details=1").concat(d?"&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 ns({request:t,features:n,options:a}))}},{key:"_statLogConnection",value:function(e){var t;this._dispatcher.dispatch(new De(new Pe({type:Ae.WEBSOCKET_CONNECT,data:{host_url:null===(t=this.sdkState.websocket)||void 0===t?void 0:t.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,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=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=void 0,this._rejectConnectionRequest(A.connectionCanceled)),a=this._url(n),s=new ca,this._connectionRequestQueue.push(s),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){i._loginTimer=void 0,i._rejectConnectionRequest(A.loginTimeout)}),null===(e=this.sdkState.websocket)||void 0===e?void 0:e.responseTimeout),n&&(this._sessionManager.auth.authToken=n),this._websocketClient.connect(a)),t.abrupt("return",s.promise);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"cancelConnectForRetry",value:function(){this._dispatcher.dispatch(ts.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=void 0,this._unresolvedLogi=void 0,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=void 0)}}]),a}(se),as=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._disableWebSocketCloseEventHandling=!1,this._externalCalledWebSocketClose=!1,this._logger=l,this._disableWebSocketCloseEventHandling=d,this._context=new rs(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=void 0),this._websocketEventDispatcherContext&&(this._websocketEventDispatcherContext.close(),this._websocketEventDispatcherContext=void 0)}},{key:"isConnected",get:function(){return this._context.currentState.type===sa.CONNECTED}},{key:"isConnecting",get:function(){var e=this._context.currentState;return e.type===sa.CONNECTING||e.type===sa.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(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,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}(),ss=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)}(Pe),is=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=le.POST,a.path="".concat(xe),a.params={device_id:s,log_entries:i.map((function(e){return Pe.payloadify(e)}))},a}return s(n)}(Oe),os=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"}(Ja||(Ja={}));var us,cs=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=Ja.PENDING,t.isFlushing=!1,t.generation=1,t.lastFlushedAt=0,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===Ja.ENABLED}},{key:"_arrangeStat",value:function(){var e=[];this._collectRequestStat&&e.push.apply(e,_(this.queue.filter((function(e){return e.type===Ae.API_RESULT||e.type===Ae.WEBSOCKET_CONNECT})))),this._collectFeatureLocalCacheStat&&e.push.apply(e,_(this.queue.filter((function(e){return e.type===Ae.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!==Ja.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 Pe.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 ss){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 is({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=Ja.DISABLED,e.next=30;break;case 29:e.t0.code===E.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Ja.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 Pe({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,ba(a);case 13:return t.next=15,this._flush();case 15:this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(e){if(e instanceof De){var t=e.statLog;s.put(t)}else if(e instanceof ns){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?Ja.ENABLED:Ja.COLLECT_ONLY:s.enabledState=Ja.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===Ja.DISABLED){t.next=7;break}return e instanceof ss?this._collectFeatureLocalCacheStat&&(r=this.queue.filter((function(t){return t instanceof ss&&t.key===e.key})),a=v(r,1),(s=a[0])?s.data=os(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=void 0)}}]),a}(se);e.LogLevel=void 0,(us=e.LogLevel||(e.LogLevel={}))[us.NONE=0]="NONE",us[us.VERBOSE=1]="VERBOSE",us[us.DEBUG=2]="DEBUG",us[us.INFO=3]="INFO",us[us.WARN=4]="WARN",us[us.ERROR=5]="ERROR";var ls,hs=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 ue(ce({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}))}}]),t}(),Es=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 ue(ce({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}))}}]),e}(),ws=function(){function e(t){r(this,e),this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,this.url=t.url,t.secure_url&&(this.secureUrl=t.secure_url),t.type&&(this.type=t.type),t.width&&(this.width=t.width),t.height&&(this.height=t.height),t.alt&&(this.alt=t.alt)}return s(e,null,[{key:"payloadify",value:function(e){var t,n;return ue(ce({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}))}}]),e}(),Cs=function(){function e(t){r(this,e),this.title=null,this.url=null,this.description=null,this.defaultImage=null,t["og:title"]&&(this.title=t["og:title"]),t["og:url"]&&(this.url=t["og:url"]),t["og:description"]&&(this.description=t["og:description"]),t["og:image"]&&(this.defaultImage=new ws(t["og:image"]))}return s(e,null,[{key:"payloadify",value:function(e){return ue(ce({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?ws.payloadify(e.defaultImage):null}))}}]),e}(),xs=function(){function e(t){var n,a;r(this,e),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 ue(ce({name:e.name,volume:e.volume}))}}]),e}(),Ts=function(t){i(a,t);var n=f(a);function a(t,s){var i,o;return r(this,a),(i=n.call(this,t,s)).isBlockedByMe=!1,i.role=D(e.Role,s.role)?s.role:e.Role.NONE,i.isBlockedByMe=null!==(o=s.is_blocked_by_me)&&void 0!==o&&o,i}return s(a,null,[{key:"payloadify",value:function(e){return ue(ce(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})))}}]),a}(Xa);e.ScheduledStatus=void 0,(gs=e.ScheduledStatus||(e.ScheduledStatus={})).PENDING="pending",gs.SENT="sent",gs.FAILED="failed",gs.CANCELED="canceled",function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(ys||(ys={}));var Ss,Is=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"}},Ns=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,E;r(this,a),(i=n.call(this,t)).channelType=e.ChannelType.BASE,i.parentMessage=null,i.silent=!1,i.isOperatorMessage=!1,i.messageType=e.MessageType.BASE,i.mentionType=null,i.threadInfo=null,i.reactions=[],i.metaArrays=[],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,i.mentionedUsers=s.mentioned_users?s.mentioned_users.map((function(e){return new Xa(i._iid,e)})):null,i.mentionedUserIds=null!==(d=s.mentioned_user_ids)&&void 0!==d?d:null,i.mentionedUsers&&!i.mentionedUserIds&&(i.mentionedUserIds=i.mentionedUsers.map((function(e){return e.userId}))),i.mentionedMessageTemplate=null!==(f=s.mentioned_message_template)&&void 0!==f?f:"",i.threadInfo=s.thread_info?new ms(i._iid,s.thread_info):null,i.reactions=s.reactions?s.reactions.map((function(e){return new bs(e)})):[];var w=null!==(p=s.metaarray)&&void 0!==p?p:{},C=null!==(v=s.metaarray_key_order)&&void 0!==v?v:Object.keys(w).sort((function(e,t){return e.localeCompare(t)}));i.metaArrays=[];for(var x=0;x=t)return this.parentMessage=e,!0}return!1}}],[{key:"payloadify",value:function(e){var t,n,r,s;return ue(ce(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:Is(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 Xa.payloadify(e)})),mentioned_message_template:e.mentionedMessageTemplate,thread_info:e.threadInfo?ms.payloadify(e.threadInfo):null,reactions:e.reactions.map((function(e){return bs.payloadify(e)})),sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return Es.payloadify(e)})),og_tag:e.ogMetaData?Cs.payloadify(e.ogMetaData):null,silent:e.silent,is_op_msg:e.isOperatorMessage,apple_critical_alert_options:e.appleCriticalAlertOptions?xs.payloadify(e.appleCriticalAlertOptions):null,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})))}},{key:"_getParentMessageInfoPayload",value:function(e){return ue(ce({type:e.messageType,ts:e.createdAt,user:e.sender?Ts.payloadify(e.sender):null,message:e.message,file:{url:e.plainUrl,name:e.name,type:e.type,require_auth:e.requireAuth}}))}}]),a}(Ha),Ms=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)).reqId="",i.replyToChannel=!1,i.errorCode=0,i.sender=s.user?new Ts(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(s.scheduled_status&&(i._scheduledStatus=s.scheduled_status),s.scheduled_status){case ys.SENT:case ys.IN_QUEUE:i.sendingStatus=e.SendingStatus.SUCCEEDED;break;case ys.PENDING:i.sendingStatus=e.SendingStatus.SCHEDULED;break;case ys.FAILED:case ys.REMOVED:i.sendingStatus=e.SendingStatus.FAILED;break;case ys.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 ue(ce(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{user:Ts.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode})))}}]),a}(Ns),As=function(){function e(t){var n,a;r(this,e),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 ue(ce({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}))}}]),e}(),Os={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},Us=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)},Rs=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)).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;s.parentMessage=Bs(t,ue(ce(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}))))}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({},Os),n),Za(this.messageId>0&&L("number",e)&&Us(a)).throw(A.invalidParameters),s=wi.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 ue(ce(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{message:e.message,translations:e.translations,parent_message_info:e.parentMessage?p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage):null})))}}]),u}(Ns),Ls=function(){function e(t){var n,a;r(this,e),this.detail={},this.type=null!==(n=t.type)&&void 0!==n?n:"",this.vendor=null!==(a=t.vendor)&&void 0!==a?a:"",t.detail&&L("object",t.detail)&&!Array.isArray(t.detail)&&(this.detail=t.detail)}return s(e,null,[{key:"payloadify",value:function(e){return ue(ce({type:e.type,vendor:e.vendor,detail:e.detail}))}}]),e}();!function(e){e.OPEN="open",e.CLOSED="closed"}(Ss||(Ss={}));var Ds="removed",Ps=function(e){switch(e){case"open":return Ss.OPEN;case"closed":return Ss.CLOSED;default:return null}},Fs=function(e){return!e||!!e.text&&L("string",e.text)},Gs=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 ue(ce(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})))}}]),n}(Ha),qs=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=Ss.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=Ps(a.status))&&void 0!==h?h:Ss.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 Gs(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=Ps(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 Gs(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 Wa(this)}}],[{key:"payloadify",value:function(e){return ue(ce(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 Gs.payloadify(e)})),created_by:e.createdBy,allow_user_suggestion:e.allowUserSuggestion,allow_multiple_votes:e.allowMultipleVotes,voted_option_ids:e.votedPollOptionIds})))}}]),n}(Ha),Hs=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 Ls(e)})):[],s._poll=n.poll?new qs(s._iid,n.poll):null,n.parent_message_info){var v=n.parent_message_info;s.parentMessage=Bs(t,ue(ce(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}))))}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({},Os),n),Za(this.messageId>0&&L("number",e)&&Us(a)).throw(A.invalidParameters),s=wi.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 ue(ce(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 Ls.payloadify(e)})),poll:e._poll?qs.payloadify(e._poll):null,parent_message_info:e.parentMessage?p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage):null})))}}]),u}(Ms),js=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o,u,c,l;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=null!==(i=a.url)&&void 0!==i?i:"",s.fileName=null!==(o=a.file_name)&&void 0!==o?o:null,s.mimeType=null!==(u=a.file_type)&&void 0!==u?u:null,s.fileSize=null!==(c=a.file_size)&&void 0!==c?c:0,s._requireAuth=null!==(l=a.require_auth)&&void 0!==l&&l;var h=fs.of(s._iid).sessionManager;return s.thumbnails=a.thumbnails?a.thumbnails.map((function(e){return new As(Object.assign(Object.assign({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(s._requireAuth?"?auth=".concat(h.ekey):"")}))})):[],s}return s(n,[{key:"url",get:function(){var e=fs.of(this._iid).sessionManager;return this._requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl}}],[{key:"payloadify",value:function(e){var t;return ue(ce({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}(Ha),zs=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 js(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;s.parentMessage=Bs(t,ue(ce(Object.assign(Object.assign({},d),{created_at:d.ts,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}))))}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({},Os),n),Za(this.messageId>0&&L("number",e)&&Us(a)).throw(A.invalidParameters),s=wi.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 ue(ce(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 js.payloadify(e)})):null,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage):null})))}},{key:"_isMultipleFilesMessagePayload",value:function(e){var t=e.files;return Array.isArray(t)&&t.length>=2}},{key:"_isMultipleFilesMessageSerializedData",value:function(e){var t=e.fileInfoList;return Array.isArray(t)}}]),u}(Ms),Vs=function(t){switch(t.messageType){case e.MessageType.USER:return Hs.payloadify(t);case e.MessageType.FILE:return t.fileInfoList?zs.payloadify(t):Qs.payloadify(t);case e.MessageType.ADMIN:return Rs.payloadify(t);default:throw A.unknown}},Bs=function(e,t){switch(t.type){case"MESG":return new Hs(e,t);case"FILE":return zs._isMultipleFilesMessagePayload(t)?new zs(e,t):new Qs(e,t);case"ADMM":case"BRDM":return new Rs(e,t)}throw A.unknown},Qs=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;r(this,u),(s=a.call(this,t,n)).messageParams=null,s.plainUrl="",s.requireAuth=!1,s.thumbnails=[],s.messageSurvivalSeconds=-1,s.messageType=e.MessageType.FILE;var b=n.file;s.plainUrl=(null!==(o=null!==(i=null==b?void 0:b.url)&&void 0!==i?i:n.url)&&void 0!==o?o:"").split("?auth=")[0],s.name=null!==(l=null!==(c=null==b?void 0:b.name)&&void 0!==c?c:n.name)&&void 0!==l?l:"File",s.size=null!==(d=null!==(h=null==b?void 0:b.size)&&void 0!==h?h:n.size)&&void 0!==d?d:0,s.data=null!==(p=null!==(f=null==b?void 0:b.data)&&void 0!==f?f:n.custom)&&void 0!==p?p:"",s.type=b?null!==(v=b.type)&&void 0!==v?v:"":null!==(_=n.type)&&void 0!==_?_:"";var E=fs.of(s._iid).sessionManager;if(s.requireAuth=null!==(m=n.require_auth)&&void 0!==m&&m,s.thumbnails=n.thumbnails?n.thumbnails.map((function(e){return new As(Object.assign(Object.assign({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(s.requireAuth?"?auth=".concat(E.ekey):"")}))})):[],s.messageSurvivalSeconds=null!==(g=n.message_survival_seconds)&&void 0!==g?g:-1,n.parent_message_info){var w=n.parent_message_info;s.parentMessage=Bs(t,ue(ce(Object.assign(Object.assign({},w),{created_at:w.ts,message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:w.file,url:null===(y=w.file)||void 0===y?void 0:y.url,require_auth:null===(k=w.file)||void 0===k?void 0:k.require_auth}))))}return s}return s(u,[{key:"url",get:function(){var e=fs.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({},Os),n),Za(this.messageId>0&&L("number",e)&&Us(a)).throw(A.invalidParameters),s=wi.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 ue(ce(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:e.parentMessage?p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage):null})))}}]),u}(Ms),Ks=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(ce({channel_url:t.channelUrl,files:t.files?Js(t.files):null,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?xs.payloadify(t.appleCriticalAlertOptions):null,silent:t.silent,reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId?t.parentMessageId:null,req_id:t.reqId,pin_message:t.isPinnedMessage}))})}return s(a)}(oa),Ws=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=le.POST,s.path="".concat(Te(t.channelType),"/").concat(encodeURIComponent(t.channelUrl),"/messages"),s.params=ue(ce({message_type:e.MessageType.FILE,user_id:t.userId,files:t.files?Js(t.files):null,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 As.payloadify(e)})),require_auth:t.requireAuth,sorted_metaarray:null===(o=t.metaArrays)||void 0===o?void 0:o.map((function(e){return Es.payloadify(e)})),push_option:t.pushNotificationDeliveryOption,parent_message_id:t.parentMessageId?t.parentMessageId:null,apple_critical_alert_options:t.appleCriticalAlertOptions?xs.payloadify(t.appleCriticalAlertOptions):null,reply_to_channel:t.isReplyToChannel,req_id:t.reqId,pin_message:t.isPinnedMessage})),s}return s(a)}(Oe),Ys=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l;r(this,n),(i=t.call(this,e,"FILE",s)).message=s.files&&s.files.length>=2?new zs(e,s):new Qs(e,s);var h=fs.of(e).sdkState;return i.isMentioned=Ie(i.message.mentionType,null!==(c=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})))&&void 0!==c?c:[],h.userId),i.forceUpdateLastMessage=null!==(l=s.force_update_last_message)&&void 0!==l&&l,i}return s(n)}(qe),Zs=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,a)).message=a.files&&a.files.length>=2?new zs(e,a):new Qs(e,a);var l=fs.of(e).sdkState;return s.isMentioned=Ie(s.message.mentionType,null!==(u=null!==(i=s.message.mentionedUserIds)&&void 0!==i?i:null===(o=s.message.mentionedUsers)||void 0===o?void 0:o.map((function(e){return e.userId})))&&void 0!==u?u:[],l.userId),s.forceUpdateLastMessage=null!==(c=a.force_update_last_message)&&void 0!==c&&c,s}return s(n)}(Ue);function Js(e){return e.map((function(e){var t,n;return ue(ce({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 As.payloadify(e)})),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth}))}))}var Xs;!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"}(Xs||(Xs={}));var $s=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._iid=t,this._sdkState=s,this._requestQueue=o,this._cacheContext=c,this._dispatcher=i,this._dispatcher.on((function(e){e instanceof da&&(a._connectionState=e.stateType)})),this._onlineDetector=u}return s(e,[{key:"_shouldSendThroughWebSocket",get:function(){return this._connectionState===sa.CONNECTED||this._connectionState===sa.CONNECTING||this._connectionState===sa.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 Ks(a),t.next=5,this._requestQueue.send(s);case 5:return i=t.sent,o=i.as(Ys),u=o.message,t.abrupt("return",u);case 10:return c=new Ws(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(Zs),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){var 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._queueMap.get(e.url))){t.next=58;break}if(a.isResolving){t.next=57;break}a.isResolving=!0,s=[],i=!0,o=y(a.messageQueue),t.prev=7,o.s();case 9:if((u=o.n()).done){t.next=40;break}c=u.value,t.t0=c.state,t.next=t.t0===Xs.PENDING||t.t0===Xs.UPLOADING?14:t.t0===Xs.UPLOADED?17:t.t0===Xs.FAILED?35:38;break;case 14:return i=!1,s.push(c),t.abrupt("break",38);case 17:if(!i){t.next=33;break}return t.prev=18,c.state=Xs.SENDING,t.next=22,this._sendFileMessage(e,c);case 22:return l=t.sent,c.deferred.resolve(l),t.next=26,ba(100);case 26:t.next=31;break;case 28:t.prev=28,t.t1=t.catch(18),c.deferred.reject(t.t1);case 31:t.next=34;break;case 33:s.push(c);case 34:return t.abrupt("break",38);case 35:return h=null!==(n=c.error)&&void 0!==n?n:A.unknown,c.deferred.reject(h.code===E.REQUEST_CANCELED?A.fileUploadCanceled:h),t.abrupt("break",38);case 38:t.next=9;break;case 40:t.next=45;break;case 42:t.prev=42,t.t2=t.catch(7),o.e(t.t2);case 45:return t.prev=45,o.f(),t.finish(45);case 48:if(d=a.isResolveRequestPending,a.messageQueue=s,a.isResolving=!1,a.isResolveRequestPending=!1,!d){t.next=55;break}return t.next=55,this._resolveMessageQueue(e);case 55:t.next=58;break;case 57:a.isResolveRequestPending=!0;case 58:case"end":return t.stop()}}),r,this,[[7,42,45,48],[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))){t.next=30;break}if(!(s=a.messageQueue.find((function(e){return e.state===Xs.PENDING})))){t.next=30;break}if(!s.multipleFileUploadInfo){t.next=19;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=13;break}return t.next=11,this._tryUploadNextItemAndUpdateItemState(e,a,s);case 11:t.next=14;break;case 13: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 vs({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(_s),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 vs({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(_s),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=void 0,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,a){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 ca,c={requestId:n,params:r,state:Xs.PENDING,deferred:u},ei(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,t){var 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 Xs.PENDING:i.state=Xs.FAILED,i.error=A.requestCanceled,this._resolveMessageQueue(e);break;case Xs.UPLOADING:this._requestQueue.cancel(i.requestId)}}}catch(e){s.e(e)}finally{s.f()}}}}]),e}();function ei(e){return"fileInfoList"in e}var ti,ni={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:e.ReplyType.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},ri=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)},ai={replyType:e.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},si=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,(ti=e.MessageEventSource||(e.MessageEventSource={})).UNKNOWN="UNKNOWN",ti.EVENT_MESSAGE_SENT_SUCCESS="EVENT_MESSAGE_SENT_SUCCESS",ti.EVENT_MESSAGE_SENT_FAILED="EVENT_MESSAGE_SENT_FAILED",ti.EVENT_MESSAGE_SENT_PENDING="EVENT_MESSAGE_SENT_PENDING",ti.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",ti.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",ti.EVENT_MESSAGE_DELETED="EVENT_MESSAGE_DELETED",ti.EVENT_MESSAGE_READ="EVENT_MESSAGE_READ",ti.EVENT_MESSAGE_DELIVERED="EVENT_MESSAGE_DELIVERED",ti.EVENT_MESSAGE_REACTION_UPDATED="EVENT_MESSAGE_REACTION_UPDATED",ti.EVENT_MESSAGE_THREADINFO_UPDATED="EVENT_MESSAGE_THREADINFO_UPDATED",ti.EVENT_MESSAGE_OFFSET_UPDATED="EVENT_MESSAGE_OFFSET_UPDATED",ti.REQUEST_MESSAGE="REQUEST_MESSAGE",ti.EVENT_POLL_UPDATED="EVENT_POLL_UPDATED",ti.EVENT_POLL_VOTED="EVENT_POLL_VOTED",ti.SYNC_POLL_CHANGELOGS="SYNC_POLL_CHANGELOGS",ti.REQUEST_RESEND_MESSAGE="REQUEST_RESEND_MESSAGE",ti.REQUEST_THREADED_MESSAGE="REQUEST_THREADED_MESSAGE",ti.REQUEST_MESSAGE_CHANGELOGS="REQUEST_MESSAGE_CHANGELOGS",ti.SYNC_MESSAGE_FILL="SYNC_MESSAGE_FILL",ti.SYNC_MESSAGE_BACKGROUND="SYNC_MESSAGE_BACKGROUND",ti.SYNC_MESSAGE_CHANGELOGS="SYNC_MESSAGE_CHANGELOGS",ti.LOCAL_MESSAGE_PENDING_CREATED="LOCAL_MESSAGE_PENDING_CREATED",ti.LOCAL_MESSAGE_FAILED="LOCAL_MESSAGE_FAILED",ti.LOCAL_MESSAGE_CANCELED="LOCAL_MESSAGE_CANCELED",ti.LOCAL_MESSAGE_RESEND_STARTED="LOCAL_MESSAGE_RESEND_STARTED";var ii,oi=function(t){return t.startsWith("EVENT_")||t===e.MessageEventSource.SYNC_MESSAGE_FILL||t===e.MessageEventSource.SYNC_MESSAGE_CHANGELOGS||t===e.MessageEventSource.SYNC_POLL_CHANGELOGS},ui=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.messages,i=e.source,o=e.isWebSocketEventComing,u=void 0!==o&&o;return r(this,n),(a=t.call(this)).messages=s,a.source=i,a.isWebSocketEventComing=u,a}return s(n)}(oe),ci=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.messageIds,i=e.source,o=e.isWebSocketEventComing,u=void 0!==o&&o;return r(this,n),(a=t.call(this)).messageIds=s,a.source=i,a.isWebSocketEventComing=u,a}return s(n)}(oe),li=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),hi=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),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=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.event,i=e.source;return r(this,n),(a=t.call(this)).event=s,a.source=i,a}return s(n)}(oe),pi=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=le.GET,a.path="".concat(Te(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)}(Oe),vi=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?Bs(e,Object.assign({},a)):null,s}return s(n)}(Ue),_i=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.prevResultSize,l=e.nextResultSize,h=e.isInclusive,d=e.reverse,f=e.messageTypeFilter,p=e.customTypesFilter,v=e.senderUserIdsFilter,_=e.replyType,m=e.includeMetaArray,g=e.includeReactions,y=e.parentMessageId,k=e.includeThreadInfo,b=e.includeParentMessageInfo,E=e.showSubchannelMessagesOnly,w=e.checkingContinuousMessages;return r(this,n),(a=t.call(this)).method=le.GET,a.path="".concat(Te(s),"/").concat(encodeURIComponent(i),"/messages"),a.params=ue(ce({is_sdk:!0,prev_limit:c,next_limit:l,include:h,reverse:d,message_ts:o,message_id:u,message_type:null!=f?f:null,custom_types:p,sender_ids:v,include_reply_type:_,with_sorted_meta_array:m,include_reactions:g,parent_message_id:y,include_thread_info:k,include_parent_message_info:b,show_subchannel_message_only:E,include_poll_details:!0,checking_continuous_messages:w})),a}return s(n)}(Oe),mi=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 Bs(e,t)})),s}return s(n)}(Ue),gi=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=le.GET,a.path="".concat(Te(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)}(Oe),yi=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 Bs(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)}(Ue),ki=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=le.GET,a.path="".concat(pe,"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i)),a.params={},a}return s(n)}(Oe),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)).message=a?Bs(e,Object.assign({},a)):null,s}return s(n)}(Ue),Ei={},wi=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 $s(e,{sdkState:a,dispatcher:s,requestQueue:i,onlineDetector:o,cacheContext:u}),Ei[e]=this}return s(n,[{key:"buildMessageFromSerializedData",value:function(t){var n=Ya(t);switch(n.messageType){case e.MessageType.USER:return new Hs(this._iid,Hs.payloadify(n));case e.MessageType.FILE:return zs._isMultipleFilesMessageSerializedData(n)?new zs(this._iid,zs.payloadify(n)):new Qs(this._iid,Qs.payloadify(n));case e.MessageType.ADMIN:return new Rs(this._iid,Rs.payloadify(n))}throw A.invalidParameters}},{key:"buildUserMessageCreateParamsFromSerializedData",value:function(e,t){return ue(ce({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(ce({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=Ya(e);return new Ts(this._iid,Ts.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 pi(e),t.next=3,this._requestQueue.send(r);case 3:return a=t.sent,s=a.as(vi),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 ki(e),t.next=3,this._requestQueue.send(r);case 3:return a=t.sent,s=a.as(bi),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 _i(Object.assign(Object.assign({channelType:r,channelUrl:n,token:String(a)},ni),s)),e.next=3,this._requestQueue.send(o);case 3:return u=e.sent,c=u.as(mi),l=c.messages,this._dispatcher.dispatch(new ui({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 _i(Object.assign(Object.assign({channelType:r,channelUrl:n,timestamp:a},ni),s)),e.next=3,this._requestQueue.send(o);case 3:return u=e.sent,c=u.as(mi),l=c.messages,this._dispatcher.dispatch(new ui({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 _i(Object.assign(Object.assign(Object.assign({channelType:r,channelUrl:n,timestamp:a},ni),s),{checkingContinuousMessages:o})),e.next=3,this._requestQueue.send(u);case 3:return c=e.sent,l=c.payload,h=c.as(mi),d=h.messages,this._dispatcher.dispatch(new ui({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 _i(Object.assign(Object.assign(Object.assign({channelUrl:n.channelUrl,channelType:n.channelType,timestamp:r},Os),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(mi),l=c.messages,(h=l.slice(1)).forEach((function(e){e.parentMessage=n})),this._dispatcher.dispatch(new ui({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 gi(ue(ce(Object.assign(Object.assign({channelType:r,channelUrl:n,timestamp:"number"==typeof a?a:null,token:"string"==typeof a?a:null},ai),s)))),e.next=3,this._requestQueue.send(o);case 3:return u=e.sent,c=u.as(yi),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 ui({messages:l,source:i})),p.length>0&&this._dispatcher.dispatch(new ci({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 Ei[e]}}]),n}(),Ci=function(){function t(){r(this,t),this._onPending=He,this._onFailed=He,this._onSucceeded=He}return s(t,[{key:"_trigger",value:function(t,n){switch(null==n?void 0: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)).targetMessageId=0;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 ms(e,i),s.targetMessageId=o,s.channelUrl=u,s.channelType=c),s}return s(n)}(Ha),Ti={channelUrl:"",channelType:e.ChannelType.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},Si=function(t){return L("string",t.channelUrl)&&D(e.ChannelType,t.channelType)&&L("number",t.messageId)&&L("boolean",t.includeReactions,!0)&&L("boolean",t.includeMetaArray,!0)&&L("boolean",t.includeParentMessageInfo,!0)&&L("boolean",t.includeThreadInfo,!0)},Ii=function(){function e(t,n){var a;r(this,e),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}(),Ni=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=le.GET,a.path="".concat(ge,"/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)}(Oe),Mi=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 Bs(e,t)})),s.hasNext=a.has_next,s.nextToken=a.end_cursor,s.totalCount=a.total_count,s}return s(n)}(Ue);e.MessageSearchOrder=void 0,(ii=e.MessageSearchOrder||(e.MessageSearchOrder={})).SCORE="score",ii.TIMESTAMP="ts";var Ai,Oi,Ui,Ri=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=fs.of(this._iid),r=n.requestQueue,a=new Ni(ce(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(Mi),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}(Ii),Li=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}(Ii),Di=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=wi.of(this._iid),e.next=7,n.getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,ce({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}(Li),Pi={channelUrl:"",scheduledMessageId:0},Fi=function(e){return L("string",e.channelUrl)&&""!==e.channelUrl&&L("number",e.scheduledMessageId)&&e.scheduledMessageId>0},Gi=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.apply(this,arguments))._onFileUploaded=He,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}(Ci),qi=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 wi(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({},Ti),e),Za(Si(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({},Pi),e),Za(Fi(r)).throw(A.invalidParameters),t.abrupt("return",this._manager.getScheduledMessage(r));case 3:case"end":return t.stop()}}),n,this)})))}}]),a}(ps),Hi=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=le.POST,a.path=Ee,a.params={title:s,options:i,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return s(n)}(Oe),ji=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 qs(e,a),s}return s(n)}(Ue),zi=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=le.GET,a.path="".concat(Ee,"/").concat(encodeURIComponent(o)),a.params={channel_url:s,channel_type:i},a}return s(n)}(Oe),Vi=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 qs(e,a),s}return s(n)}(Ue),Bi=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=le.GET,a.path="".concat(Ee,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u)),a.params={channel_url:s,channel_type:i},a}return s(n)}(Oe),Qi=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 Gs(e,a),s}return s(n)}(Ue),Ki=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=le.GET,a.path="".concat(Te(s),"/").concat(encodeURIComponent(i),"/polls/changelogs"),a.params=ue({change_ts:o,token:u}),a}return s(n)}(Oe),Wi=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 new qs(e,t)}(e,t)})),s.deletedPollIds=a.deleted.map((function(e){return e})),s.hasMore=a.has_more,s.nextToken=a.next,s}return s(n)}(Ue),Yi={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},Zi=function(e){return L("string",e.title)&&(t=e.optionTexts,F("string",t)&&t.every((function(e){return""!==e.trim()})))&&Fs(e.data)&&L("boolean",e.allowUserSuggestion,!0)&&L("boolean",e.allowMultipleVotes,!0)&&L("number",e.closeAt,!0);var t},Ji={channelUrl:"",channelType:e.ChannelType.BASE,pollId:0,pollOptionId:0},Xi=function(t){return L("string",t.channelUrl)&&""!==t.channelUrl&&D(e.ChannelType,t.channelType)&&L("number",t.pollId)&&t.pollId>0&&L("number",t.pollOptionId)&&t.pollOptionId>0},$i={channelUrl:"",channelType:e.ChannelType.BASE,pollId:0},eo=function(t){return L("string",t.channelUrl)&&""!==t.channelUrl&&D(e.ChannelType,t.channelType)&&L("number",t.pollId)},to={},no=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,to[e]=this}return s(n,[{key:"buildPollFromSerializedData",value:function(e){var t=Ya(e);return new qs(this._iid,qs.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 Za(eo(e)).throw(A.invalidParameters),r=new zi(Object.assign({},e)),t.next=4,this._requestQueue.send(r);case 4:return a=t.sent,s=a.as(Vi),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;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(Zi(e)).throw(A.invalidParameters),r=new Hi(Object.assign({},e)),t.next=4,this._requestQueue.send(r);case 4:return a=t.sent,s=a.as(ji),i=s.poll,t.abrupt("return",i);case 7: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 Za(Xi(e)).throw(A.invalidParameters),r=new Bi(Object.assign({},e)),t.next=4,this._requestQueue.send(r);case 4:return a=t.sent,s=a.as(Qi),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 Ki(ce({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(Wi),c=u.updatedPolls,l=u.deletedPollIds,h=u.hasMore,d=u.nextToken,c.length>0&&this._dispatcher.dispatch(new hi({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 to[e]}}]),n}(),ro=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})),ao=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})),so=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=le.GET,a.path=Ee,a.params={channel_url:s,channel_type:i,token:o,limit:u},a}return s(n)}(Oe),io=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 qs(e,t)})),s.token=a.next,s}return s(n)}(Ue),oo=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=fs.of(this._iid),r=n.requestQueue,a=new so(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(io),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}(Li),uo=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=le.GET,a.path="".concat(Ee,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u),"/voters"),a.params={channel_url:s,channel_type:i,token:c,limit:l},a}return s(n)}(Oe),co=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 Xa(e,t)})),s.token=a.next,s}return s(n)}(Ue),lo=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=fs.of(this._iid),r=n.requestQueue,a=new uo(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(co),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}(Li),ho=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 no(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({},Yi),e),Za(Zi(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({},$i),e),Za(eo(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({},Ji),e),Za(Xi(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}(ps),fo={profileImage:void 0,profileUrl:void 0,nickname:void 0},po=function(e){return q(e.profileImage,!0)&&L("string",e.profileUrl,!0)&&L("string",e.nickname,!0)},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.onSessionExpired=He,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=He,this.onSessionRefreshed=He,this.onSessionClosed=He}))),_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.onConnected=He,this.onReconnectStarted=He,this.onReconnectSucceeded=He,this.onReconnectFailed=He,this.onDisconnected=He}))),mo=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=He,this.onTotalUnreadMessageCountUpdated=He}))),go="GroupChannel",yo=100,ko="Message";e.GroupChannelListOrder=void 0,(Ai=e.GroupChannelListOrder||(e.GroupChannelListOrder={})).LATEST_LAST_MESSAGE="latest_last_message",Ai.CHRONOLOGICAL="chronological",Ai.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",Ai.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.PublicGroupChannelListOrder=void 0,(Oi=e.PublicGroupChannelListOrder||(e.PublicGroupChannelListOrder={})).CHRONOLOGICAL="chronological",Oi.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",Oi.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.ScheduledMessageListOrder=void 0,(Ui=e.ScheduledMessageListOrder||(e.ScheduledMessageListOrder={})).CREATED_AT="created_at",Ui.SCHEDULED_AT="scheduled_at";var bo,Eo=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"];default:return["-lastMessageUpdatedAt","-createdAt","syncIndex"]}},wo=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 Ms))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 Ms&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!0}}]),t}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(bo||(bo={}));var Co,xo=function(e){switch(e){case bo.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case bo.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},To={data:void 0,customType:void 0,mentionType:e.MentionType.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,mentionedMessageTemplate:void 0,metaArrays:void 0,parentMessageId:void 0,isReplyToChannel:!1,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0,isPinnedMessage:!1},So=function(t){return L("string",t.data,!0)&&L("string",t.customType,!0)&&D(e.MentionType,t.mentionType)&&F("string",t.mentionedUserIds,!0)&&F(Xa,t.mentionedUsers,!0)&&L("string",t.mentionedMessageTemplate,!0)&&F(Es,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)},Io=function(e){return{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}},No=Object.assign(Object.assign({},To),{message:"",translationTargetLanguages:void 0,pollId:void 0}),Mo=function(e){var t;return ue(ce({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)}))},Ao=function(e){return So(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"}(Co||(Co={}));var Oo,Uo,Ro=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},Lo=function(e){return e===Co.BLOB||e===Co.FILE},Do=function(e){return{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}},Po=Object.assign(Object.assign({},To),{file:void 0,fileKey:void 0,fileUrl:void 0,fileName:void 0,fileType:void 0,fileSize:void 0,mimeType:void 0,thumbnailSizes:void 0,requireAuth:!1}),Fo=function(e,t){var n;return e.messageParams?(!e.url&&q(t)&&(e.messageParams.file=t),e.messageParams):ue(ce({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,file:t,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:null===(n=e.thumbnails)||void 0===n?void 0:n.map((function(e){return{maxWidth:e.width,maxHeight:e.height}}))}))},Go=function(e){return So(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})))},qo=function(){return"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product},Ho=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"}(Oo||(Oo={})),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"}(Uo||(Uo={}));var jo,zo={},Vo=function(){function e(t){var n=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return r(this,e),this._state=Oo.PROCESSING,this._queue=[],this._activationQueue=[],zo[t]&&!a.forceCreate||(this.nodeId=Ho(),this.key=t,qo()&&(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 Uo.NEWNODE:n._sendSync();break;case Uo.CLAIM_HOST:n._sendSync(),n._hostId=r;break;case Uo.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:Uo.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 Uo.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 Uo.REQUEST_LOCK:n._requestLock(t);break;case Uo.ACQUIRE_LOCK:var d=n._queue.find((function(e){return e.requestId===a}));n._acquire(d);break;case Uo.RELEASE_LOCK:n._release(a)}})),window.addEventListener("beforeunload",(function(){n._send(Uo.REMOVENODE)}))),zo[t]=this),zo[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==Oo.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:Ho(),key:this.key,op:e,data:n.data,ts:Date.now()};return qo()&&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(Uo.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(Uo.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(Uo.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=Oo.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])}},{key:"registerNode",value:function(){this._send(Uo.NEWNODE),this._waitSync()}},{key:"claimHost",value:function(){this._hostId=this.nodeId,this._send(Uo.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(Uo.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}(),Bo=Object.assign(Object.assign({},No),{scheduledAt:void 0}),Qo=Object.assign(Object.assign({},To),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Ko=Object.assign(Object.assign({},To),{fileInfoList:[]}),Wo=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})))},Yo="UnsentMessage",Zo={},Jo=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,Zo[e]=d(s),s._mutex=new Vo("unsendmessagecache.lock"),s}return s(a,[{key:"collection",get:function(){var e=this._cacheContext.nestdb,t=null==e?void 0:e.collection(Yo);if(!t)throw A.databaseError;return t}},{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 Hs?(e.messageParams&&(n.messageParams=Io(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,Object.assign(Object.assign({},Io(t)),{scheduledAt:t.scheduledAt})))):e instanceof Qs?(e.messageParams&&(n.messageParams=Do(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return Object.assign(Object.assign({},Do(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))):e instanceof zs&&e.messageParams&&(n.messageParams=function(e){return ue({fileInfoList:e.fileInfoList,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption})}(e.messageParams)),n}},{key:"_deserialize",value:function(e){return e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)}),wi.of(this._iid).buildMessageFromSerializedData(e)}},{key:"_deserializeWithMessageCreateParams",value:function(e){var n,r,a;return b(this,void 0,void 0,t().mark((function s(){var i,o,u,c,l,h,d,f=this;return t().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:if(i=wi.of(this._iid),o=this._deserialize(e),!e.messageParams){s.next=32;break}if(!(o instanceof Hs)){s.next=8;break}u=e.messageParams,o.messageParams=i.buildUserMessageCreateParamsFromSerializedData(u,o),s.next=32;break;case 8:if(!(o instanceof Qs)){s.next=26;break}if(!(c=e.messageParams).fileKey||"string"!=typeof c.fileKey||!Lo(null!==(n=c.fileType)&&void 0!==n?n:"")){s.next=23;break}return s.next=13,this.collection.getBlob(c.fileKey);case 13:if(s.t1=r=s.sent,s.t0=null!==s.t1,!s.t0){s.next=17;break}s.t0=void 0!==r;case 17:if(!s.t0){s.next=21;break}s.t2=r,s.next=22;break;case 21:s.t2=void 0;case 22:c.file=s.t2;case 23:o.messageParams=i.buildFileMessageCreateParamsFromSerializedData(c,o),s.next=32;break;case 26:if(!(o instanceof zs)){s.next=32;break}if(!(l=e.messageParams)||!l.fileInfoList){s.next=32;break}return o.messageParams=i.buildMultipleFilesMessageCreateParamsFromSerializedData(l,o),s.next=32,Promise.all(o.messageParams.fileInfoList.map((function(e){return b(f,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:if("string"!=typeof(null===(r=e._uploadedMetaData)||void 0===r?void 0:r.fileKey)||!Lo(null!==(s=null===(a=e._uploadedMetaData)||void 0===a?void 0:a.fileType)&&void 0!==s?s:"")){t.next=13;break}return t.next=3,this.collection.getBlob(e._uploadedMetaData.fileKey);case 3:if(t.t1=i=t.sent,t.t0=null!==t.t1,!t.t0){t.next=7;break}t.t0=void 0!==i;case 7:if(!t.t0){t.next=11;break}t.t2=i,t.next=12;break;case 11:t.t2=void 0;case 12:e.file=t.t2;case 13:case"end":return t.stop()}}),n,this)})))})));case 32:if(!(o.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams)){s.next=54;break}if(!(o instanceof Hs)){s.next=38;break}h=e.scheduledInfo.scheduledMessageParams,o.scheduledInfo.scheduledMessageParams=i.buildScheduledUserMessageCreateParamsFromSerializedData(h,o),s.next=54;break;case 38:if(!(o instanceof Qs)){s.next=54;break}if(!(d=e.scheduledInfo.scheduledMessageParams).fileKey||"string"!=typeof d.fileKey||"string"!=typeof d.fileType||!Lo(d.fileType)){s.next=53;break}return s.next=43,this.collection.getBlob(d.fileKey);case 43:if(s.t4=a=s.sent,s.t3=null!==s.t4,!s.t3){s.next=47;break}s.t3=void 0!==a;case 47:if(!s.t3){s.next=51;break}s.t5=a,s.next=52;break;case 51:s.t5=void 0;case 52:d.file=s.t5;case 53:o.scheduledInfo.scheduledMessageParams=i.buildScheduledFileMessageCreateParamsFromSerializedData(d,o);case 54:return s.abrupt("return",o);case 55:case"end":return s.stop()}}),s,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",void 0);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"fetch",value:function(e){var n=e.channelUrl,r=e.filter,a=void 0===r?new wo:r,s=e.order,i=void 0===s?bo.CHANNEL_LATEST:s,o=e.sendingStatus,u=e.backward,c=void 0!==u&&u,l=e.parentMessageId;return b(this,void 0,void 0,t().mark((function e(){var r,s,u,h,d,f=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=13;break}return r=xo(i),s={"/where":function(e){return!!(i!==bo.NEWEST_CHILD_MESSAGE||l&&0!==e.parentMessageId&&e.parentMessageId===l)&&a.match(f._deserialize(e))}},n&&(s.channelUrl=n),o&&(s.sendingStatus=o),u={where:s,index:r,backward:c},e.next=8,this.collection.query(u);case 8:return h=e.sent,e.next=11,h.fetch({});case 11:return d=e.sent,e.abrupt("return",Promise.all(d.map((function(e){return b(f,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 wo;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:bo.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 Qs||e instanceof zs)){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;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=[],!(e.threadInfo&&e.threadInfo.replyCount>0)){t.next=5;break}return t.next=4,this.getAllChildMessages(e);case 4:r=t.sent;case 5:if(!(r.length>0)){t.next=9;break}return r.forEach((function(t){return t.applyParentMessage(e)})),t.next=9,this.upsert(r);case 9:case"end":return t.stop()}}),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 Qs)){n.next=19;break}if(!e.messageParams){n.next=9;break}if(!(r=e.messageParams).file||!Ro(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=Co.BLOB;case 9:if(!e.scheduledInfo||!e.scheduledInfo.scheduledMessageParams){n.next=17;break}if(!(s=e.scheduledInfo.scheduledMessageParams).file||!Ro(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=Co.BLOB;case 17:n.next=24;break;case 19:if(!(e instanceof zs)){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;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!n.file||!Ro(n.file)){t.next=7;break}return t.next=3,this.collection.saveBlob(n.file,this._getFileInfoBlobKey(e.reqId,r));case 3:s=t.sent,n._uploadedMetaData||(n._uploadedMetaData={}),n._uploadedMetaData.fileKey=s,n._uploadedMetaData.fileType=Co.BLOB;case 7:case"end":return t.stop()}}),a,this)})))})));case 24:case"end":return n.stop()}}),n,this)})))}}],[{key:"of",value:function(e){return Zo[e]}}]),a}(Ha),Xo=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:go,keyName:"url",index:[Eo(e.GroupChannelListOrder.LATEST_LAST_MESSAGE),Eo(e.GroupChannelListOrder.CHRONOLOGICAL),Eo(e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:ko,keyName:"messageId",index:[xo(bo.CHANNEL_LATEST),xo(bo.NEWEST_CHILD_MESSAGE)]},{collectionName:Yo,keyName:"reqId",index:[xo(bo.CHANNEL_LATEST),xo(bo.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()}},$o={},eu=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,$o[e]=d(s),s}return s(a,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return Za(!!e).throw(A.databaseError),e.collection(ko)}},{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)}),wi.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",void 0);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?yo:a,i=e.filter,o=void 0===i?new wo:i,u=e.order,c=void 0===u?bo.CHANNEL_LATEST:u,l=e.backward,h=void 0!==l&&l,d=e.parentMessageId,f=e.isPollOnly,p=void 0!==f&&f;return b(this,void 0,void 0,t().mark((function e(){var a,i,u,l,f=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 bo.CHANNEL_LATEST:if(!h&&e.createdAt>r||h&&e.createdAt1&&void 0!==arguments[1]?arguments[1]:new wo;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:bo.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)&&e.threadInfo.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(bo.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(bo.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(bo.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 Qs&&e.messageParams)){t.next=7;break}if(!(r=e.messageParams).file||!Ro(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 $o[e]}}]),a}(Ha),tu=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},nu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.getVisibilityState,i=void 0===s?tu: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._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=void 0),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((function(){e._pauseDelayTimer=void 0,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),ru=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:le.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))})));case 5:case"end":return e.stop()}}),e,this)})))}}]),e}(),au=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),su={},iu=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,su[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 da)switch(e.stateType){case sa.CONNECTED:a._isProcessingAutoResend||a.processAutoResendRegisteredPendingMessages().then((function(){return a._processNextAutoResend()}));break;case sa.INTERNAL_DISCONNECTED:case sa.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 ui({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 ui({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=Jo.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 au({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 su[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"}(jo||(jo={}));var ou,uu=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 Xa(e,r),blockee:new Xa(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 Xa(e,t)})):[]}}}]),e}(),cu=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,(ou=e.GroupChannelEventSource||(e.GroupChannelEventSource={})).UNKNOWN="UNKNOWN",ou.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",ou.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",ou.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",ou.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",ou.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",ou.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",ou.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",ou.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",ou.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",ou.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",ou.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",ou.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",ou.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",ou.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",ou.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",ou.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",ou.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",ou.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",ou.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",ou.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",ou.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",ou.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",ou.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",ou.EVENT_PINNED_MESSAGE_UPDATED="EVENT_PINNED_MESSAGE_UPDATED",ou.REQUEST_CHANNEL="REQUEST_CHANNEL",ou.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",ou.REFRESH_CHANNEL="REFRESH_CHANNEL",ou.CHANNEL_LASTACCESSEDAT_UPDATED="CHANNEL_LASTACCESSEDAT_UPDATED",ou.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",ou.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS";var lu,hu=function(t){return t.startsWith("EVENT_")||t===e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS||t===e.GroupChannelEventSource.REFRESH_CHANNEL},du=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channels,i=e.source,o=e.isWebSocketEventComing,u=void 0!==o&&o,c=e.data,l=void 0===c?null:c;return r(this,n),(a=t.call(this)).channels=s,a.source=i,a.isWebSocketEventComing=u,a.data=l,a}return s(n)}(oe),fu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrls,i=e.source,o=e.isWebSocketEventComing,u=void 0!==o&&o;return r(this,n),(a=t.call(this)).channelUrls=s,a.source=i,a.isWebSocketEventComing=u,a}return s(n)}(oe),pu=function(e){i(n,e);var t=f(n);function n(){return r(this,n),t.call(this)}return s(n)}(oe),vu=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 uu(s),i}return s(n)}(qe),_u=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.nickname,o=e.profileUrl,u=e.profileImage,c=e.preferredLanguages;return r(this,n),(a=t.call(this)).method=le.PUT,a.path="".concat(de,"/").concat(encodeURIComponent(s)),a.params=ue(ce({nickname:i,profile_url:o,profile_file:u,preferred_languages:c})),a}return s(n)}(Oe),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)).user=new Xa(e,Object.assign({},a)),s}return s(n)}(Ue),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=le.POST,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push/apns"),a.params={apns_device_token:i,always_push:!0},a}return s(n)}(Oe),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=le.POST,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push/gcm"),a.params={gcm_reg_token:i,always_push:!0},a}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=le.DELETE,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push/apns/").concat(encodeURIComponent(i)),a}return s(n)}(Oe),bu=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=le.DELETE,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push/gcm/").concat(encodeURIComponent(i)),a}return s(n)}(Oe),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=le.DELETE,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push/apns"),a}return s(n)}(Oe),wu=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=le.DELETE,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push/gcm"),a}return s(n)}(Oe),Cu=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=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push/").concat(encodeURIComponent(i),"/device_tokens"),a.params={created_ts:u,token:o},a}return s(n)}(Oe),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)}(Ue),Tu=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=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/channel_invitation_preference"),a}return s(n)}(Oe),Su=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)}(Ue),Iu=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=le.PUT,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/channel_invitation_preference"),a.params={auto_accept:i},a}return s(n)}(Oe),Nu=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)}(Ue),Mu=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=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push_preference"),a}return s(n)}(Oe),Au=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)}(Ue),Ou=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=le.PUT,a.path="".concat(de,"/").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)}(Oe),Uu=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)}(Ue),Ru=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=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push_preference"),a}return s(n)}(Oe),Lu=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)}(Ue),Du=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=le.PUT,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push_preference"),a.params={snooze_enabled:i,snooze_start_ts:o,snooze_end_ts:u},a}return s(n)}(Oe),Pu=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)}(Ue),Fu=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=le.POST,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/block"),a.params={target_id:i},a}return s(n)}(Oe),Gu=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=le.DELETE,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/block/").concat(encodeURIComponent(i)),a}return s(n)}(Oe),qu=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=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push_preference"),a}return s(n)}(Oe),Hu=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)}(Ue),ju=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=le.PUT,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push_preference"),a.params={push_trigger_option:i},a}return s(n)}(Oe),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)).pushTriggerOption=a.push_trigger_option,s}return s(n)}(Ue),Vu=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=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push/template"),a}return s(n)}(Oe),Bu=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)}(Ue),Qu=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=le.PUT,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push/template"),a.params={name:i},a}return s(n)}(Oe),Ku=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)}(Ue),Wu=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=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/friends/changelogs"),a.params={token:i},a}return s(n)}(Oe),Yu=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 Xa(e,t)})),updatedUsers:a.updated.map((function(t){return new Xa(e,t)})),deletedUserIds:a.deleted,hasMore:a.has_more,token:a.next},s}return s(n)}(Ue),Zu=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=le.PUT,a.path="".concat(de,"/").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)}(Oe),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)).friendDiscoveryRequestId=a.friend_discovery_request_id,s}return s(n)}(Ue),Xu=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=le.DELETE,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/friend_discoveries"),a.params={friend_discovery_keys:i},a}return s(n)}(Oe),$u=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=le.POST,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/friends"),a.params={user_ids:i},a}return s(n)}(Oe),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)).users=a.users.map((function(t){return new Xa(e,t)})),s}return s(n)}(Ue),tc=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=le.DELETE,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/friends"),a.params={user_ids:i},a}return s(n)}(Oe),nc=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=le.GET,a.path="".concat(de,"/").concat(s,"/allow_friend_discovery"),a.params={},a}return s(n)}(Oe),rc=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)}(Ue),ac=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=le.PUT,a.path="".concat(de,"/").concat(s,"/allow_friend_discovery"),a.params={allow_friend_discovery:i},a}return s(n)}(Oe),sc=s((function e(t){r(this,e),this.key=t.key,this.url=t.url})),ic=s((function e(t){r(this,e),this.id=t.id,this.name=t.name,this.url=t.url,this.emojis=t.emojis?t.emojis.map((function(e){return new sc(e)})):[]})),oc=s((function e(t){r(this,e),this.emojiHash=t.emoji_hash||"",this.emojiCategories=t.emoji_categories?t.emoji_categories.map((function(e){return new ic(e)})):[]})),uc=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.call(this)).method=le.GET,e.path=be,e}return s(n)}(Oe),cc=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 oc(a),s}return s(n)}(Ue),lc=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=le.GET,a.path="".concat(be,"/").concat(s),a}return s(n)}(Oe),hc=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 ic(a),s}return s(n)}(Ue),dc=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=le.GET,a.path="".concat(ke,"/").concat(s),a}return s(n)}(Oe),fc=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 sc(a),s}return s(n)}(Ue),pc=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.call(this)).method=le.GET,e.path="".concat(Ce),e}return s(n)}(Oe),vc=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)}(Ue),_c=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=le.GET,a.path=de,a.params=ue({limit:s,token:i,user_ids:o,metadatakey:u,metadatavalues_in:c,nickname_startswith:l}),a}return s(n)}(Oe),mc=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 Xa(e,t)})),s.next=a.next,s}return s(n)}(Ue),gc=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=fs.of(this._iid),r=n.requestQueue,a=new _c(ce(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(mc),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}(Ii),yc=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=le.GET,a.path="".concat(de,"/").concat(s,"/block"),a.params=ue({limit:i,token:o,user_ids:u}),a}return s(n)}(Oe),kc=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 Xa(e,t)})),s.next=a.next,s}return s(n)}(Ue),bc=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=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new yc(ce(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(kc),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}(Ii),Ec=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=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/friends"),a.params={limit:i,token:o},a}return s(n)}(Oe),wc=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 Xa(e,t)})),s.next=a.next,s}return s(n)}(Ue),Cc=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=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Ec(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(wc),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}(Ii),xc={},Tc=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"}(lu||(lu={}));var Sc,Ic=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.code,i=void 0===s?lu.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:lu.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})}},{key:"storeNotAvailable",get:function(){return new n({code:lu.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})}},{key:"storeNotAvailableInPrivateBrowsing",get:function(){return new n({code:lu.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:lu.STORE_IS_FULL,message:"Store is full."})}},{key:"storeNotInitialized",get:function(){return new n({code:lu.STORE_NOT_INITIALIZED,message:"Store is not initialized."})}},{key:"storeKeyTypeIsInvalid",get:function(){return new n({code:lu.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})}},{key:"storeBrokenIntegrity",get:function(){return new n({code:lu.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:lu.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:lu.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})}},{key:"storeItemSizeExceeded",get:function(){return new n({code:lu.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:lu.STORE_READ_FAILED,message:"Failed to read from store."})}},{key:"storeWriteFailed",get:function(){return new n({code:lu.STORE_WRITE_FAILED,message:"Failed to write to store."})}},{key:"databaseSchemaNotOnUpgrade",get:function(){return new n({code:lu.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})}},{key:"collectionNotReady",get:function(){return new n({code:lu.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})}},{key:"collectionKeyNotMatch",get:function(){return new n({code:lu.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})}},{key:"collectionQueryNotValid",get:function(){return new n({code:lu.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})}},{key:"collectionInsertDuplicate",get:function(){return new n({code:lu.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})}},{key:"collectionKeyNotFound",get:function(){return new n({code:lu.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})}},{key:"collectionKeyNotGiven",get:function(){return new n({code:lu.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})}},{key:"collectionWriteFailed",get:function(){return new n({code:lu.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})}},{key:"collectionItemSizeExceeded",get:function(){return new n({code:lu.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:lu.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})}},{key:"indexTypesNotMatch",get:function(){return new n({code:lu.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})}},{key:"compareTypesNotMatch",get:function(){return new n({code:lu.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})}},{key:"circularReferenceFound",get:function(){return new n({code:lu.CIRCULAR_REFERENCE_FOUND,message:"Cannot handle circular referenced object."})}}]),n}(h(Error));!function(e){e.INIT="init",e.READY="ready",e.CLOSED="closed"}(Sc||(Sc={}));var Nc,Mc=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 Ic.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},Ac=function(e,t){if(null==t)return 1;if(null==e)return-1;if(n(e)!==n(t))throw Ic.compareTypesNotMatch;var r=0;switch(n(e)){case"boolean":case"number":r=e-t;break;case"string":r=e.localeCompare(t)}return r},Oc=function(e,t){for(var n=0,r=0;r>>0)%t},Uc=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Rc=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(!(Ac(u,c)>0))return!1;break;case"/gte":case">=":var l=r[s],h=i[o];if(!(Ac(l,h)>=0))return!1;break;case"/lt":case"<":var d=r[s],f=i[o];if(!(Ac(d,f)<0))return!1;break;case"/lte":case"<=":var p=r[s],v=i[o];if(!(Ac(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)},Lc=function(){},Dc=function(){return Promise.resolve()},Pc=function(e){return e},Fc=function(e,t){t()};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Nc||(Nc={}));var Gc,qc,Hc,jc=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?Pc:u,l=t.backward,h=void 0===l?Dc:l,d=t.forward,f=void 0===d?Dc:d,p=t.complete,v=void 0===p?Lc: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}(),zc=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*Ac(this._indexer.origin[l].columnValues[s],this.condition[i][c])<=0){a=l;break}}else for(var h=a;h>=0;h--)if(o*Ac(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 Ic.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(Yc(e,t)).concat(n,".").concat(r)},Jc=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=Zc(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=Yc(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"}(Gc||(Gc={})),function(e){e.PENDING="pending",e.PERSISTENT="persistent",e.VOLATILE="volatile"}(qc||(qc={})),function(e){e[e.NO_CACHE=0]="NO_CACHE",e[e.DEFAULT=1]="DEFAULT",e[e.PERSISTENT=2]="PERSISTENT"}(Hc||(Hc={}));var Xc,$c=[qc.PENDING,qc.VOLATILE],el={},tl=function(){function e(t){var n=t.dbname,a=t.limit,s=void 0===a?256:a;return r(this,e),el[n]||(this.dbname=n,this._items=[],this._limit=s,el[n]=this),el[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]:Hc.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===Hc.PERSISTENT?qc.PERSISTENT:qc.VOLATILE},this.put(s)),t.next=9;break;case 8:r===Hc.PERSISTENT&&(s.state=qc.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]:Hc.DEFAULT,n=this._items.map((function(e){return e.key})).indexOf(e);if(n>-1){var r=this._items[n];return t===Hc.PERSISTENT&&(r.state=qc.PERSISTENT),t!==Hc.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)$c.includes(this._items[t].state)&&$c.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===qc.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===qc.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!==qc.VOLATILE}))}}],[{key:"get",value:function(e){return el[e]}}]),e}(),nl=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(Qc(e,t),"/trans.metadata")}(n,a),this.recordsetKey=function(e,t){return"".concat(Qc(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=tl.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=tl.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||Oc)(e,r)}(e,s,{hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant})),"".concat(Wc(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=tl.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=rl.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=Tc.get(this.dbname),s=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/a.itemSizeLimit),o=tl.get(this.dbname),t.next=6,o.find(this._store,s);case 6:if(u=t.sent,!(null==(c=u?rl.createFromCacheItem(u):new rl({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=Wc(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:tl.get(this.dbname).clearByCondition((function(e){return e.key.startsWith(n)}));case 11:case"end":return e.stop()}}),e,this)})))}}]),e}(),sl={},il=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(Qc(e,t),"/index.").concat(n)}(a,s,o.join(">"));return sl[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(Gc.COMMIT,this.indexerKey,(function(){return n.commit()})),this._transaction.on(Gc.ERROR,this.indexerKey,(function(){return n.abort()}))),sl[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 Ic.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=Ac(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=tl.get(this.dbname),e.next=3,n.find(this._store,this.indexerKey,Hc.PERSISTENT);case 3:if(r=e.sent){e.next=33;break}return a=Wc(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,Hc.NO_CACHE);case 17:if(c=e.sent,l=rl.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=Mc(this._origin);case 35:sl[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 tl.get(this.dbname).remove(this.indexerKey),e.next=4,this._store.remove(this.indexerKey);case 4:delete sl[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=Mc(this._origin)}},{key:"abort",value:function(){this._table=Mc(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 sl)delete sl[e]}}]),e}(),ol=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=Sc.INIT,this._indexers=[],this.dbname=a,this.name=s,this.keyName=i,this.indexes=[[i]].concat(_(u.filter((function(e){return il.createKey(e)!==n.keyName})))),this._keyHash=o,this._store=c,this._mutex=new Vo(function(e,t){return"".concat(Qc(e,t),".lock")}(a,s)),this._blobContainer=new Jc({dbname:a,collectionName:s,store:c}),this._transaction=new nl({dbname:a,collectionName:s,store:c})}return s(e,[{key:"state",get:function(){return this._state}},{key:"isReady",get:function(){return this._state===Sc.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=Tc.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 al({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 il.createKey(e)})),u=a?a.indexes.map((function(e){return il.createKey(e)})):[],c=y(u);try{for(c.s();!(l=c.n()).done;)h=l.value,o.includes(h)||i.push(il.parseKey(h))}catch(e){c.e(e)}finally{c.f()}return(d=[]).push.apply(d,_(s.map((function(e){var t=new il({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 il({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=Kc(this.dbname,this.name),this._metadata.indexes=s,t.next=29,this._store.set({key:f,value:this._metadata});case 29:this._state=Sc.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=Sc.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=il.createKey(e),r=y(this._indexers);try{for(r.s();!(t=r.n()).done;){var a=t.value;if(n===il.createKey(a.fields))return a}}catch(e){r.e(e)}finally{r.f()}throw Ic.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=Kc(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 Ic.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",Mc(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 Ic.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 Vc({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Ic.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 Ic.collectionKeyNotGiven;case 6:return t.next=8,this._requestInsert(Mc(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 Ic.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 Ic.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(Mc(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 Ic.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 Ic.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpsert(Mc(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 Ic.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 Ic.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(Mc(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 Ic.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 Ic.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpdate(Mc(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 Ic.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 zc({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,Rc(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 Ic.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}(),cl={},ll=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 cl[this.dbname]},set:function(e){cl[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(!cl[this.dbname]){e.next=4;break}return e.abrupt("return",Object.keys(cl[this.dbname]));case 4:throw Ic.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(!cl[this.dbname]){t.next=6;break}return t.next=3,Uc(this.delay);case 3:return t.abrupt("return",cl[this.dbname][e]?Object.assign({key:e},cl[this.dbname][e]):null);case 6:throw Ic.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(!cl[this.dbname]){t.next=7;break}return t.next=3,Uc(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,cl[this.dbname][i]=Object.freeze({data:o,metadata:u})}catch(e){r.e(e)}finally{r.f()}t.next=8;break;case 7:throw Ic.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(!cl[this.dbname]){t.next=7;break}return t.next=3,Uc(this.delay);case 3:r=y(e);try{for(r.s();!(a=r.n()).done;)s=a.value,cl[this.dbname][s]&&delete cl[this.dbname][s]}catch(e){r.e(e)}finally{r.f()}t.next=8;break;case 7:throw Ic.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,cl[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,Uc(this.delay);case 2:cl[this.dbname]={};case 3:case"end":return e.stop()}}),e,this)})))}}]),a}(ul),hl="NestDBStore";!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(Xc||(Xc={}));var dl,fl=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=hl,e._state=Xc.UNINITIALIZED,e._openJobQueue=[],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:"state",get:function(){return this._state}},{key:"_openDatabase",value:function(e){var t=this;return new Promise((function(n,r){if(t._indexedDb){t._state=Xc.OPENING;var a=t._indexedDb.open(e);a.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(hl,{keyPath:"key"})})),a.addEventListener("success",(function(r){t._state=Xc.OPEN,t._database=r.target.result,t._openJobQueue.forEach((function(e){return e()})),t._openJobQueue=[],t._database.onclose=function(){t._database=void 0,t._state=Xc.OPENING,setTimeout((function(){t._openDatabase(e)}),5)},n(t._database)})),a.addEventListener("error",(function(e){t._state=Xc.UNINITIALIZED,r(e.target.error)}))}else r(Ic.storeNotAvailable)}))}},{key:"_getObjectStore",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:if(!this._database){t.next=4;break}return t.abrupt("return",this._database.transaction(this._storeName,e).objectStore(this._storeName));case 4:t.t0=this._state,t.next=t.t0===Xc.UNINITIALIZED||t.t0===Xc.OPEN?7:t.t0===Xc.OPENING||t.t0===Xc.CLOSED?8:9;break;case 7:throw Ic.storeNotInitialized;case 8:return t.abrupt("return",new Promise((function(t){r._openJobQueue.push((function(){return t(r._getObjectStore(e))}))})));case 9:return t.next=11,this._getObjectStore(e);case 11:return t.abrupt("return",t.sent);case 12:case"end":return t.stop()}}),n,this)})))}},{key:"_getAllRawKeys",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._getObjectStore("readonly");case 2:return n=e.sent,e.next=5,new Promise((function(e,t){var r=n.getAllKeys();r.addEventListener("success",(function(t){e(t.target.result)})),r.addEventListener("error",(function(e){return t(e.target.error)}))}));case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"_getRaw",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._getObjectStore("readonly");case 2:return r=t.sent,t.next=5,new Promise((function(t,n){var a=r.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 5:return t.abrupt("return",t.sent);case 6: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;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._getObjectStore("readwrite");case 2:return r=t.sent,t.next=5,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 5: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 t.next=2,this._getObjectStore("readwrite");case 2:return r=t.sent,t.next=5,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 5:case"end":return t.stop()}}),n,this)})))}},{key:"_triggerDatabaseClose",value:function(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))}},{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||!qo()){e.next=13;break}if(!(qo()&&navigator.userAgent&&navigator.userAgent.includes("Edge/"))){e.next=9;break}if(this._window.indexedDB||!n.PointerEvent&&!n.MSPointerEvent){e.next=7;break}throw Ic.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(Ic.storeNotAvailableInPrivateBrowsing)},n.onsuccess=function(){return e()}}catch(e){t(Ic.storeNotAvailableInPrivateBrowsing)}else t(Ic.storeNotAvailable)}));case 11:e.next=14;break;case 13:case 16:throw Ic.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(){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,this._openDatabase(e);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"clear",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._getObjectStore("readwrite");case 2:return n=e.sent,e.next=5,new Promise((function(e,t){var r=n.clear();r.addEventListener("success",(function(){return e()})),r.addEventListener("error",(function(e){return t(e.target.error)}))}));case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)})))}}]),a}(ul),pl=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 wl(e,t)}))),s}return s(n)}(Ue),Dl=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=fs.of(this._iid),r=n.requestQueue,a=new Rl(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Ll),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}(Li),Pl=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=le.GET,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/ban"),a.params=ue({limit:o,token:u}),a}return s(n)}(Oe),Fl=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).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 wl(e,t.user)}))),s}return s(n)}(Ue),Gl=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=fs.of(this._iid),r=n.requestQueue,a=new Pl(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Fl),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}(Li);e.ReportCategory=void 0,(bl=e.ReportCategory||(e.ReportCategory={})).SPAM="spam",bl.HARASSING="harassing",bl.SUSPICIOUS="suspicious",bl.INAPPROPRIATE="inappropriate";var ql,Hl,jl=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=le.POST,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/operators"),a.params={operator_ids:o},a}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.operatorUserIds;return(a=t.call(this)).method=le.DELETE,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/operators"),a.params={operator_ids:o},a}return s(n)}(Oe),Vl=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=le.GET,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/mute/").concat(o),a}return s(n)}(Oe),Bl=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=0,s.endAt=0;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)}(Ue),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.keys;return(a=t.call(this)).method=le.GET,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={keys:o,include_ts:!0},a}return s(n)}(Oe),Kl=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.metadata,o=a.ts;return s.metadata=i,s.ts=o,s}return s(n)}(Ue),Wl=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=le.POST,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={metadata:o,include_ts:!0},a}return s(n)}(Oe),Yl=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)}(Ue),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.metadata,u=e.upsert;return(a=t.call(this)).method=le.PUT,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={metadata:o,include_ts:!0,upsert:null!=u&&u},a}return s(n)}(Oe),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);var i=a.metadata,o=a.ts;return s.metadata=i,s.ts=o,s}return s(n)}(Ue),Xl=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),s.data&&(i.created=s.data.created,i.updated=s.data.updated,i.deleted=s.data.deleted),i}return s(n)}(qe),$l=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=le.DELETE,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/metadata/").concat(o),a.params={include_ts:!0},a}return s(n)}(Oe),eh=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.ts;return s.ts=i,s}return s(n)}(Ue),th=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=le.DELETE,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={include_ts:!0},a}return s(n)}(Oe),nh=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.ts;return s.ts=i,s}return s(n)}(Ue),rh=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=le.GET,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={keys:o},a}return s(n)}(Oe),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)).metaCounter=a,s}return s(n)}(Ue),sh=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=le.POST,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={metacounter:o},a}return s(n)}(Oe),ih=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)}(Ue),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.metaCounter,u=e.upsert,c=void 0!==u&&u,l=e.mode,h=void 0===l?"set":l;return(a=t.call(this)).method=le.PUT,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={metacounter:o,upsert:c,mode:h},a}return s(n)}(Oe),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)).metaCounter=a,s}return s(n)}(Ue),ch=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),s.data&&(i.created=s.data.created,i.updated=s.data.updated,i.deleted=s.data.deleted),i}return s(n)}(qe),lh=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=le.DELETE,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/metacounter/").concat(o),a.params={},a}return s(n)}(Oe),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;return(a=t.call(this)).method=le.DELETE,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={},a}return s(n)}(Oe),dh=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=le.POST,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/mute"),a.params={user_id:o,seconds:u,description:c},a}return s(n)}(Oe),fh=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 wl(e,s.data),i}return s(n)}(qe),ph=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=le.DELETE,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/mute/").concat(encodeURIComponent(o)),a}return s(n)}(Oe),vh=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 wl(e,s.data),i}return s(n)}(qe),_h=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=le.POST,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/ban"),a.params=ue({user_id:o,seconds:u,description:c}),a}return s(n)}(Oe),mh=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 wl(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)}(qe),gh=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=le.DELETE,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/ban/").concat(encodeURIComponent(o)),a}return s(n)}(Oe),yh=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 wl(e,s.data),i}return s(n)}(qe),kh=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=le.PUT,a.path="".concat(Te(i),"/").concat(encodeURIComponent(s),"/freeze"),a.params={freeze:o},a}return s(n)}(Oe),bh=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)}(qe),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.category,u=e.userId,c=e.description;return(a=t.call(this)).method=le.POST,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s)),a.params={report_category:o,reporting_user_id:u,report_description:c},a}return s(n)}(Oe),wh=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=le.POST,s.path="".concat(ye,"/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)}(Oe),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.category,u=e.userId,c=e.offendingUserId,l=e.messageId,h=e.description;return(a=t.call(this)).method=le.POST,a.path="".concat(Se(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)}(Oe),xh=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(ce({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?t.parentMessageId:null,req_id:t.reqId,poll_id:t.pollId,pin_message:t.isPinnedMessage}))})}return s(a)}(oa),Th=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l;r(this,n),(i=t.call(this,e,"MESG",s)).message=new Hs(e,s);var h=fs.of(e).sdkState;return i.isMentioned=Ie(i.message.mentionType,null!==(c=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})))&&void 0!==c?c:[],h.userId),i.forceUpdateLastMessage=null!==(l=s.force_update_last_message)&&void 0!==l&&l,i}return s(n)}(qe),Sh=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:"MEDI",ackRequired:!0,payload:ue(ce({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:s,mentioned_message_template:t.mentionedMessageTemplate,apple_critical_alert_options:t.appleCriticalAlertOptions?xs.payloadify(t.appleCriticalAlertOptions):null,poll_id:t.pollId}))})}return s(a)}(oa),Ih=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l,h;r(this,n),(i=t.call(this,e,"MEDI",s)).message=new Hs(e,s);var d=fs.of(e).sdkState;return i.mentionCountChange=Ne({mentionType:null===(o=s.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=s.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},ce({mentionType:i.message.mentionType,mentionedUserIds:null!==(l=i.message.mentionedUserIds)&&void 0!==l?l:null===(h=i.message.mentionedUsers)||void 0===h?void 0:h.map((function(e){return e.userId}))}),d.userId),i}return s(n)}(qe),Nh=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(ce({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)}(oa),Mh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l,h;r(this,n),(i=t.call(this,e,"FEDI",s)).message=new Qs(e,s);var d=fs.of(e).sdkState;return i.mentionCountChange=Ne({mentionType:null===(o=s.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=s.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},ce({mentionType:i.message.mentionType,mentionedUserIds:null!==(l=i.message.mentionedUserIds)&&void 0!==l?l:null===(h=i.message.mentionedUsers)||void 0===h?void 0:h.map((function(e){return e.userId}))}),d.userId),i}return s(n)}(qe),Ah=function(e){i(n,e);var t=f(n);function n(e){var a;return r(this,n),(a=t.call(this)).method=le.DELETE,a.path="".concat(Te(e.channelType),"/").concat(e.channelUrl,"/messages/").concat(e.messageId),a}return s(n)}(Oe),Oh=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)}(qe),Uh=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=le.POST,a.path="".concat(Te(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return s(n)}(Oe),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)).reactionEvent=new ks(a),s}return s(n)}(Ue),Lh=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=le.DELETE,a.path="".concat(Te(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return s(n)}(Oe),Dh=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 ks(Object.assign({},a)),s}return s(n)}(Ue),Ph=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=le.POST,a.path="".concat(Te(s),"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(o),"/translation"),a.params={target_langs:u},a}return s(n)}(Oe),Fh=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 Hs(e,a),s}return s(n)}(Ue),Gh=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=le.POST,s.path="".concat(Te(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),s.params=ue(ce({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 Es.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?xs.payloadify(t.appleCriticalAlertOptions):null,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption})),s}return s(a)}(Oe),qh=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 Hs(e,a),s}return s(n)}(Ue),Hh=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=le.POST,s.path="".concat(Te(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),s.params=ce({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 As.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 Es.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?xs.payloadify(t.appleCriticalAlertOptions):null,push_option:t.pushNotificationDeliveryOption}),s}return s(a)}(Oe),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)).message=new Qs(e,a),s}return s(n)}(Ue),zh=function(e){return L("string",e.title,!0)&&Fs(e.data)&&L("boolean",e.allowUserSuggestion,!0)&&L("boolean",e.allowMultipleVotes,!0)&&L("number",e.closeAt,!0)},Vh=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=le.PUT,a.path="".concat(Ee,"/").concat(encodeURIComponent(s)),a.params={title:i,data:o,allow_user_suggestion:u,allow_multiple_votes:c,close_at:l},a}return s(n)}(Oe),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 qs(e,a),s}return s(n)}(Ue),Qh=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=le.DELETE,a.path="".concat(Ee,"/").concat(encodeURIComponent(s)),a}return s(n)}(Oe),Kh=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=le.PUT,a.path="".concat(Ee,"/").concat(encodeURIComponent(s),"/close"),a}return s(n)}(Oe),Wh=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 qs(e,a),s}return s(n)}(Ue),Yh=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=le.POST,a.path="".concat(Ee,"/").concat(encodeURIComponent(o),"/options"),a.params={channel_url:s,channel_type:i,text:u},a}return s(n)}(Oe),Zh=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 qs(e,a),s}return s(n)}(Ue),Jh=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=le.PUT,a.path="".concat(Ee,"/").concat(encodeURIComponent(s),"/options/").concat(encodeURIComponent(i)),a.params={text:o},a}return s(n)}(Oe),Xh=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 qs(e,a),s}return s(n)}(Ue),$h=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=le.DELETE,a.path="".concat(Ee,"/").concat(encodeURIComponent(s),"/options/").concat(encodeURIComponent(i)),a}return s(n)}(Oe),ed=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)}(oa),td=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=new ao(s),i.channelUrl=s.channel_url,i.channelType=s.channel_type,i}return s(n)}(qe),nd=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)).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 Xa(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 Ul(this._iid,this.url,this.channelType,e)}},{key:"createMutedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Dl(this._iid,this.url,this.channelType,e)}},{key:"createBannedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Gl(this._iid,this.url,this.channelType,e)}},{key:"createPreviousMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Di(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 Za(F("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.requestQueue,s=new jl({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 Za(F("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.requestQueue,s=new zl({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=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Vl({channelUrl:this.url,channelType:this.channelType,userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Bl),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 Za(F("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.requestQueue,s=new Ql({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,a.send(s);case 5:return i=t.sent,o=i.as(Kl),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=fs.of(this._iid),r=n.requestQueue,a=new Ql({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(Kl),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=fs.of(this._iid),a=r.requestQueue,s=new Wl({channelUrl:this.url,channelType:this.channelType,metadata:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(Yl),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=fs.of(this._iid),s=a.requestQueue,i=new Zl({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(Jl),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 Za(L("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.requestQueue,s=new $l({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,a.send(s);case 5:i=t.sent,o=i.as(eh),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=fs.of(this._iid),r=n.requestQueue,a=new th({channelUrl:this.url,channelType:this.channelType}),e.next=4,r.send(a);case 4:s=e.sent,i=s.as(nh),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 Za(F("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.requestQueue,s=new rh({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,a.send(s);case 5:return i=t.sent,o=i.as(ah),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=fs.of(this._iid),r=n.requestQueue,a=new rh({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(ah),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=fs.of(this._iid),a=r.requestQueue,s=new sh({channelUrl:this.url,channelType:this.channelType,metaCounter:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(ih),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=fs.of(this._iid),s=a.requestQueue,i=new oh({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(uh),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=fs.of(this._iid),a=r.requestQueue,s=new oh({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(uh),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=fs.of(this._iid),a=r.requestQueue,s=new oh({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(uh),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 Za(L("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.requestQueue,s=new lh({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=fs.of(this._iid),r=n.requestQueue,a=new hh({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 Za(L("string",e)&&L("number",n,!0)&&L("string",r,!0)).throw(A.invalidParameters),s=fs.of(this._iid),i=s.requestQueue,o=new dh({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 Za(L("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.requestQueue,s=new ph({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 Za(L("string",e)&&L("number",n,!0)&&L("string",r,!0)).throw(A.invalidParameters),s=fs.of(this._iid),i=s.requestQueue,o=new _h({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 Za(L("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.requestQueue,s=new gh({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=fs.of(this._iid),r=n.requestQueue,a=new kh({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=fs.of(this._iid),r=n.requestQueue,a=new kh({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({},ni),n),Za(L("number",e)&&ri(a)).throw(A.invalidParameters),s=wi.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({},ni),n),Za(L("number",e)&&ri(a)).throw(A.invalidParameters),s=wi.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({},ai),n),Za(L("number",e)&&si(a)).throw(A.invalidParameters),s=wi.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({},ai),n),Za(L("string",e)&&si(a)).throw(A.invalidParameters),s=wi.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=fs.of(this._iid).sessionManager;return ue(ce({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 Es.payloadify(e)})):null,apple_critical_alert_options:t.appleCriticalAlertOptions?xs.payloadify(t.appleCriticalAlertOptions):null,created_at:r,user:s.currentUser?Ts.payloadify(s.currentUser):null,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 Xa.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 Hs(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 Qs(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 zs(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({},No),e);return Za(Ao(t)).throw(A.invalidParameters),this._sendUserMessage(t)}},{key:"_sendUserMessage",value:function(n,r){var a=this,s=fs.of(this._iid),i=s.dispatcher,o=s.requestQueue;s.sessionManager;var u=null!=r?r:this._generateRequestId(),c=Date.now(),l=new Ci;return ba(2).then((function(){var r=new xh(Object.assign(Object.assign({},n),{channelUrl:a.url,channelType:a.channelType,reqId:u}));o.send(r).then((function(n){var r=n.as(Th).message;i.dispatch(new ui({messages:[r],source:e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS})),Ca((function(){return b(a,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,r));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(M(r))throw r;var s=a._createPendingUserMessage(n,u,c),o=fs.of(a._iid).cacheContext.localCacheEnabled&&G(r.code);a._markMessageAsFailed(s,r,o),i.dispatch(new ui({messages:[s],source:s.sendingStatus===e.SendingStatus.PENDING?e.MessageEventSource.REQUEST_RESEND_MESSAGE:e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED})),Ca((function(){return b(a,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(r,s));case 1:case"end":return e.stop()}}),e)})))}))}));var s=a._createPendingUserMessage(n,u,c);i.dispatch(new ui({messages:[s],source:e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING})),Ca((function(){return b(a,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 Za(e instanceof Hs&&!!e.messageParams).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 Za(e instanceof Hs&&!e.scheduledInfo).throw(A.invalidParameters),a=new ca,s=null!==(n=e.messageParams)&&void 0!==n?n:Mo(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({},Sl),n),Za(L("number",e)&&Il(a)).throw(A.invalidParameters),s=fs.of(this._iid),i=s.requestQueue,o=new Sh(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(Ih),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 Za(n instanceof u&&r instanceof Hs&&r.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===r.channelUrl&&!r.scheduledInfo).throw(A.invalidParameters),Za(!r.poll).throw(A.notSupportedError),c=new ca,l=null!==(a=r.messageParams)&&void 0!==a?a:ce(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 Za(e instanceof Hs&&e.messageId>0&&F("string",n)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.requestQueue,i=new Ph({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(Fh),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=fs.of(this._iid).requestQueue,s=Date.now(),i=this._generateRequestId();ba(2).then((function(){var a=r._createPendingScheduledUserMessage(e,i,s);Ca((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 Gh(Object.assign({reqId:i,channelType:this.channelType,channelUrl:this.url},e));a.send(o).then((function(e){var a=e.as(qh).message;Ca((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;ba(2).then((function(){var o=r._createPendingScheduledUserMessage(e,i,s);r._markMessageAsFailed(o,a),Ca((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({},Po),e);return Za(Go(t)).throw(A.invalidParameters),this._sendFileMessage(t)}},{key:"sendMultipleFilesMessage",value:function(e){var t,n=Object.assign(Object.assign({},Ko),e),r=fs.of(this._iid);Za(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5;return So(e)&&Array.isArray(e.fileInfoList)&&e.fileInfoList.length>=2&&e.fileInfoList.length<=t&&e.fileInfoList.every((function(e){return Wo(e)}))}(n,null===(t=r.appInfo)||void 0===t?void 0:t.multipleFilesMessageFileCountLimit)).throw(A.invalidParameters);var a=!!e.fileInfoList.find((function(e){var t=r.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return Za(!a).throw(A.fileSizeLimitExceededError),this._sendMultipleFilesMessage(n)}},{key:"_sendFileMessage",value:function(n,r){var a=this,s=fs.of(this._iid),i=s.dispatcher;s.sessionManager;var o=wi.of(this._iid).fileMessageQueue,u=null!=r?r:this._generateRequestId(),c=Date.now(),l=new Ci;return ba(2).then((function(){var r=a._createPendingFileMessage(n,u,c);i.dispatch(new ui({messages:[r],source:e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING})),Ca((function(){return b(a,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,r));case 1:case"end":return e.stop()}}),e)})))})),o.request(a,u,n).then((function(n){i.dispatch(new ui({messages:[n],source:e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS})),Ca((function(){return b(a,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,n));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(M(r))throw r;var s=a._createPendingFileMessage(n,u,c),o=fs.of(a._iid).cacheContext.localCacheEnabled&&G(r.code);a._markMessageAsFailed(s,r,o),i.dispatch(new ui({messages:[s],source:s.sendingStatus===e.SendingStatus.PENDING?e.MessageEventSource.REQUEST_RESEND_MESSAGE:e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED})),Ca((function(){return b(a,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(r,s));case 1:case"end":return e.stop()}}),e)})))}))}))})),l}},{key:"_autoResendFileMessage",value:function(e){Za(e instanceof Qs&&!!e.messageParams).throw(A.invalidParameters);var t=fs.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,r){var a=this,s=fs.of(this._iid),i=s.dispatcher;s.sessionManager;var o=wi.of(this._iid).fileMessageQueue,u=null!=r?r:this._generateRequestId(),c=Date.now(),l=new Gi;return ba(2).then((function(){var r=a._createPendingMultipleFilesMessage(n,u,c);i.dispatch(new ui({messages:[r],source:e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING})),Ca((function(){return b(a,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,r));case 1:case"end":return e.stop()}}),e)})))})),o.request(a,u,n,l).then((function(n){i.dispatch(new ui({messages:[n],source:e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS})),Ca((function(){return b(a,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,n));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(M(r))throw r;var s=a._createPendingMultipleFilesMessage(n,u,c);a._markMessageAsFailed(s,r),i.dispatch(new ui({messages:[s],source:e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED})),Ca((function(){return b(a,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(r,s));case 1:case"end":return e.stop()}}),e)})))}))}))})),l}},{key:"_createScheduledFileMessage",value:function(e,n,r,a){var s=this,i=fs.of(this._iid).requestQueue,o=new Hh(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(jh).message;Ca((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;ba(2).then((function(){var o=s._createPendingScheduledFileMessage(e,r,a);s._markMessageAsFailed(o,i),Ca((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){Za(e.every((function(e){return Go(Object.assign(Object.assign({},Po),e))}))).throw(A.invalidParameters);var t,n=new Ci,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),Za(e instanceof Qs&&s&&!e.scheduledInfo).throw(A.invalidParameters),i=new ca,o=Fo(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({},Nl),n),Za(L("number",e)&&Ml(a)).throw(A.invalidParameters),s=fs.of(this._iid),i=s.requestQueue,o=new Nh(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(Mh),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 Za(L("string",e)).throw(A.invalidParameters),r=wi.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 Za(n instanceof u&&r instanceof Qs&&r.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===r.channelUrl&&!r.scheduledInfo).throw(A.invalidParameters),c=new ca,l=ce(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(Za(e instanceof Ns).throw(A.invalidParameters),!(e.messageId>0)){t.next=6;break}return r=fs.of(this._iid),a=r.requestQueue,s=new Ah({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 Za(e instanceof Ns&&e.messageId>0&&L("string",n)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.requestQueue,i=new Uh({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(Rh),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 Za(e instanceof Ns&&e.messageId>0&&L("string",n)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.requestQueue,i=new Lh({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(Dh),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=fs.of(this._iid),u=o.dispatcher,c=o.requestQueue,l=new Sh({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(Ih),f=d.message,u.dispatch(new ui({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=fs.of(this._iid),u=o.dispatcher,c=o.requestQueue,l=new Nh({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(Mh),f=d.message,u.dispatch(new ui({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(Za(e instanceof Ns&&e.messageId>0&&F("string",n)).throw(A.invalidParameters),a=n.map((function(e){return new Es({key:e})})),!(e instanceof Qs)){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(Za(e instanceof Ns&&e.messageId>0&&F("string",n)).throw(A.invalidParameters),a=n.map((function(e){return new Es({key:e})})),!(e instanceof Qs)){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(Za(e instanceof Ns&&e.messageId>0&&n.every((function(e){return e instanceof Es}))).throw(A.invalidParameters),!(e instanceof Qs)){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(Za(e instanceof Ns&&e.messageId>0&&n.every((function(e){return e instanceof Es}))).throw(A.invalidParameters),!(e instanceof Qs)){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 Za(D(e.ReportCategory,n)&&L("string",r)).throw(A.invalidParameters),s=fs.of(this._iid),i=s.sdkState,o=s.requestQueue,u=new Eh({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 Za(n instanceof Xa&&D(e.ReportCategory,r)&&L("string",a)).throw(A.invalidParameters),i=fs.of(this._iid),o=i.sdkState,u=i.requestQueue,c=new wh({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 Za(n instanceof Ms&&D(e.ReportCategory,r)&&L("string",a)).throw(A.invalidParameters),i=fs.of(this._iid),o=i.sdkState,u=i.requestQueue,c=new Ch({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 Za(L("number",e)&&zh(n)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.requestQueue,i=new Vh(Object.assign({pollId:e},n)),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Bh),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),Za(r).throw(A.invalidParameters),a=fs.of(this._iid),s=a.requestQueue,i=new Qh({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),Za(r).throw(A.invalidParameters),a=fs.of(this._iid),s=a.requestQueue,i=new Kh({pollId:e}),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(Wh),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(),Za(a).throw(A.invalidParameters),s=fs.of(this._iid),i=s.requestQueue,o=new Yh({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(Zh),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(),Za(s).throw(A.invalidParameters),i=fs.of(this._iid),o=i.requestQueue,u=new Jh({pollId:e,pollOptionId:n,optionText:r}),t.next=6,o.send(u);case 6:return c=t.sent,l=c.as(Xh),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),Za(a).throw(A.invalidParameters),s=fs.of(this._iid),i=s.requestQueue,o=new $h({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),Za(s).throw(A.invalidParameters),i=fs.of(this._iid),o=i.requestQueue,u=i.dispatcher,c=new ed({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(td),d=h.event,u.dispatch(new fi({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 Za(L("number",e)).throw(A.invalidParameters),r=no.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 Za(L("string",e,!0)),r=no.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 oo(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 lo(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})}}],[{key:"payloadify",value:function(e){return ue(ce(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:e.creator?Xa.payloadify(e.creator):null,created_at:e.createdAt/1e3})))}}]),u}(Ha),rd=function(){function n(e,a,s){var i=this;r(this,n),this._storeInitialized=!1,this._iid=e,this.options=a;var o=fs.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 ru({logger:f,connectionDelegate:{reconnect:function(){var t=fs.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(){fs.of(e).connectionManager.disconnect()}}});var _=new iu(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 nu({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 da){if(n.stateType===sa.CONNECTED)_.processNonAutoResendRegisteredPendingMessages()}else if(n instanceof qe){if("USEV"===n.code){var r=n.as(vu).event;if(r.category===jo.FRIEND_DISCOVERED){var a=uu.getDataAsFriendDiscoveredEvent(e,r).friendDiscoveries;Ca((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&&e.onFriendsDiscovered(a)})));case 1:case"end":return e.stop()}}),e)})))}))}}}else if(n instanceof ua){var s=fs.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&&Ca((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&&e.onTotalUnreadMessageCountUpdated(s.all,s.customTypes)})));case 1:case"end":return e.stop()}}),e)})))}))}else n instanceof $a?c.preference.set(i._getUserProfileCacheKey(u.userId),es.payloadify(n.userProfile)):n instanceof Le&&n.error&&n.error.isSessionRevokedError&&(f.debug("session revoked."),i.disconnect())}))}return s(n,[{key:"appId",get:function(){return fs.of(this._iid).sdkState.appId}},{key:"appInfo",get:function(){var e=fs.of(this._iid).appInfo;return null!=e?e:null}},{key:"appVersion",get:function(){var e;return null!==(e=fs.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""}},{key:"debugMode",get:function(){return!!fs.of(this._iid).debugMode}},{key:"logLevel",get:function(){return fs.of(this._iid).logger.level},set:function(e){fs.of(this._iid).logger.level=e}},{key:"isCacheEnabled",get:function(){return fs.of(this._iid).cacheContext.localCacheEnabled}},{key:"localCacheConfig",get:function(){var e=fs.of(this._iid).cacheContext;return e.localCacheEnabled?e.localCacheConfig:null}},{key:"ekey",get:function(){return fs.of(this._iid).sessionManager.ekey}},{key:"currentUser",get:function(){var e;return null!==(e=fs.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null}},{key:"connectionState",get:function(){var t=fs.of(this._iid).connectionManager;return t.isConnected?e.ConnectionState.OPEN:t.isConnecting?e.ConnectionState.CONNECTING:e.ConnectionState.CLOSED}},{key:"lastConnectedAt",get:function(){var e=fs.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0}},{key:"fcmPushToken",get:function(){var e;return null!==(e=this._fcmPushToken)&&void 0!==e?e:null}},{key:"apnsPushToken",get:function(){var e;return null!==(e=this._apnsPushToken)&&void 0!==e?e:null}},{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=fs.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof ll?n.store:null;throw A.debugModeRequired}},{key:"addExtension",value:function(e,t){var n=fs.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&n.extensions&&(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=fs.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.replaceStore(new ll),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=fs.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!==dl.CLOSED&&s.nestdb.name===c){t.next=15;break}return(l=s.nestdb=new kl({name:"sendbird@".concat(a.appId,"/").concat(e,".db"),version:2,store:s.store})).on("upgrade",Xo(l,s.store)),l.on("storeReplaced",(function(e){s.replaceStore(e),s.localCacheEnabled=!1,l.on("upgrade",Xo(l,s.store))})),t.next=13,l.open();case 13:this._storeInitialized=!0,o.dispatch(new cu(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=fs.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=fs.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(Za(F("string",e)).throw(A.invalidParameters),r=eu.of(this._iid),a=Jo.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,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 Za(L("string",e)&&L("string",n,!0)).throw(A.invalidParameters),a=fs.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=fs.of(this._iid),c.dispatcher.dispatch(new pu),t.next=14;break;case 9:t.prev=9,t.t0=t.catch(2),l=fs.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 es(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=fs.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=fs.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=fs.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=fs.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=fs.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){Za(e instanceof vo).throw(A.invalidParameters),fs.of(this._iid).sessionManager.handler=e}},{key:"addUserEventHandler",value:function(e,t){Za(L("string",e)&&t instanceof mo).throw(A.invalidParameters),fs.of(this._iid).userEventHandlers.set(e,t)}},{key:"removeUserEventHandler",value:function(e){fs.of(this._iid).userEventHandlers.delete(e)}},{key:"removeAllUserEventHandler",value:function(){fs.of(this._iid).userEventHandlers.clear()}},{key:"addConnectionHandler",value:function(e,t){Za(L("string",e)&&t instanceof _o).throw(A.invalidParameters),fs.of(this._iid).connectionHandlers.set(e,t)}},{key:"removeConnectionHandler",value:function(e){fs.of(this._iid).connectionHandlers.delete(e)}},{key:"removeAllConnectionHandler",value:function(){fs.of(this._iid).connectionHandlers.clear()}},{key:"createApplicationUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new gc(this._iid,e)}},{key:"createBlockedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new bc(this._iid,e)}},{key:"createFriendListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Cc(this._iid,e)}},{key:"createMessageSearchQuery",value:function(e){return new Ri(this._iid,e)}},{key:"createPollListQuery",value:function(e){return new oo(this._iid,Object.assign({},e))}},{key:"createPollVoterListQuery",value:function(e){return new lo(this._iid,Object.assign({},e))}},{key:"buildUserFromSerializedData",value:function(e){var t=Ya(e);return new Xa(this._iid,Xa.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({},fo),e),Za(po(r)).throw(A.invalidParameters),!this.currentUser){t.next=13;break}return a=fs.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new _u(Object.assign({userId:s.userId},r)),t.next=7,i.send(o);case 7:return u=t.sent,c=u.as(mu),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(Za(F("string",e)).throw(A.invalidParameters),!this.currentUser){t.next=12;break}return r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new _u({userId:a.userId,preferredLanguages:e}),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(mu),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(Za(L("string",n)).throw(A.invalidParameters),!this.currentUser){r.next=20;break}if(r.prev=2,a=fs.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 yu({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(Za(L("string",n)).throw(A.invalidParameters),!this.currentUser){r.next=20;break}return r.prev=2,a=fs.of(this._iid),s=a.sessionManager,i=a.sdkState,o=a.requestQueue,u=new bu({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=fs.of(this._iid),a=r.sessionManager,s=r.sdkState,i=r.requestQueue,o=new wu({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(Za(L("string",n)).throw(A.invalidParameters),!this.currentUser){r.next=20;break}if(r.prev=2,a=fs.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 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.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(Za(L("string",n)).throw(A.invalidParameters),!this.currentUser){r.next=20;break}return r.prev=2,a=fs.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.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=fs.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.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=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Tu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Su),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 Za(L("boolean",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Iu({userId:a.userId,willAutoAccept:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Nu),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=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Mu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Au),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 Za(L("boolean",e)&&L("number",n)&&L("number",r)&&L("number",a)&&L("number",s)&&L("string",i)).throw(A.invalidParameters),u=fs.of(this._iid),c=u.sdkState,l=u.requestQueue,h=new Ou({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(Uu),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=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Ru({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Lu),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 Za(L("boolean",e)&&L("number",n)&&L("number",r)).throw(A.invalidParameters),s=fs.of(this._iid),i=s.sdkState,o=s.requestQueue,u=new Du({userId:i.userId,snoozeOn:e,startTs:n,endTs:r}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(Pu),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 Za(L("string",n)&&D(e.PushTokenType,r)).throw(A.invalidParameters),s=fs.of(this._iid),i=s.sdkState,o=s.requestQueue,u=s.sessionManager,c=new Cu({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=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new qu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,e.abrupt("return",i.as(Hu).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 Za(D(e.PushTriggerOption,n)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new ju({userId:s.userId,pushTriggerOption:n}),t.next=5,i.send(o);case 5:return u=t.sent,t.abrupt("return",u.as(zu).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=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Vu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,e.abrupt("return",i.as(Bu).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 Za(D(e.PushTemplate,n)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Qu({userId:s.userId,templateName:n}),t.next=5,i.send(o);case 5:return u=t.sent,t.abrupt("return",u.as(Ku).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 Za(e instanceof Xa||L("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Fu({userId:a.userId,blockedUserId:e instanceof Xa?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 Za(e instanceof Xa||L("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Gu({userId:a.userId,unblockedUserId:e instanceof Xa?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 Za(L("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Wu({userId:a.userId,token:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Yu),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=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new nc({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(rc),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 Za(L("boolean",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new ac({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=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Zu({userId:a.userId,discoveries:e}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(Ju),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 Za(F("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Xu({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 Za(F("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new $u({userId:a.userId,userIds:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(ec),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 Za(F("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new tc({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=fs.of(this._iid),r=n.requestQueue,a=new uc,e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(cc),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=fs.of(this._iid),a=r.requestQueue,s=new lc({categoryId:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(hc),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=fs.of(this._iid),a=r.requestQueue,s=new dc({key:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(fc),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=fs.of(this._iid),Za(n.hasExtension("sb_uikit")).throw(A.notSupportedError),r=n.requestQueue,a=new pc,e.next=6,r.send(a);case 6:return s=e.sent,i=s.as(vc),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=e.modules,s=void 0===a?[]:a,i=e.options,o=void 0===i?new H:i,u=e.debugMode,c=void 0!==u&&u,l=e.customApiHost,h=e.customWebSocketHost,d=e.newInstance,f=void 0!==d&&d,p=e.logLevel,v=e.localCacheEnabled,m=void 0!==v&&v,g=e.localCacheConfig,y=void 0===g?new te:g,k=e.localCacheEncryption,b=e.useAsyncStorageStore,E=void 0===b?null:b,w=e.appStateToggleEnabled,C=void 0===w||w;if(!ql||f){var x="su-".concat(re()),T=null!=k?k:{encrypt:function(e){return e},decrypt:function(e){return e}},S=new ll({encryption:T});c||(S=Fe()?E?new pl({AsyncStorage:E,encryption:T}):new ll({encryption:T}):new fl({encryption:T})),new fs(x,{appId:t,appVersion:r,options:o,apiHost:null!=l?l:"https://api-".concat(t,".sendbird.com"),websocketHost:null!=h?h:"wss://ws-".concat(t,".sendbird.com"),store:S,encryption:T,logLevel:p,localCacheEnabled:m,localCacheConfig:y,debugMode:c,appStateToggleEnabled:C});var I=[new qi,new ho],N=new n(x,o,[].concat(_(s),I));return ql||(ql=N),N}return ql}},{key:"instance",get:function(){return ql}},{key:"version",get:function(){return w}}]),n}();e.MemberState=void 0,(Hl=e.MemberState||(e.MemberState={})).NONE="none",Hl.JOINED="joined",Hl.INVITED="invited",Hl.LEFT="left";var ad,sd,id,od,ud,cd,ld,hd,dd=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,"boolean"==typeof s.is_muted&&(i.isMuted=s.is_muted),"boolean"==typeof s.is_blocked_by_me&&(i.isBlockedByMe=s.is_blocked_by_me),"boolean"==typeof s.is_blocking_me&&(i.isBlockingMe=s.is_blocking_me),i}return s(a,null,[{key:"payloadify",value:function(e){return ue(ce(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})))}}]),a}(wl),fd=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 Xa(i._iid,s.user),i.readAt=s.ts,i}return s(a)}(Ha);e.PublicChannelFilter=void 0,(ad=e.PublicChannelFilter||(e.PublicChannelFilter={})).ALL="all",ad.PUBLIC="public",ad.PRIVATE="private",e.MyMemberStateFilter=void 0,(sd=e.MyMemberStateFilter||(e.MyMemberStateFilter={})).ALL="all",sd.JOINED="joined_only",sd.INVITED="invited_only",sd.INVITED_BY_FRIEND="invited_by_friend",sd.INVITED_BY_NON_FRIEND="invited_by_non_friend",e.SuperChannelFilter=void 0,(id=e.SuperChannelFilter||(e.SuperChannelFilter={})).ALL="all",id.SUPER="super",id.NON_SUPER="nonsuper",id.BROADCAST_ONLY="broadcast_only",id.EXCLUSIVE_ONLY="exclusive_only",e.UnreadChannelFilter=void 0,(od=e.UnreadChannelFilter||(e.UnreadChannelFilter={})).ALL="all",od.UNREAD_MESSAGE="unread_message",e.HiddenChannelFilter=void 0,(ud=e.HiddenChannelFilter||(e.HiddenChannelFilter={})).ALL="all",ud.UNHIDDEN="unhidden_only",ud.HIDDEN="hidden_only",ud.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",ud.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide",e.OperatorFilter=void 0,(cd=e.OperatorFilter||(e.OperatorFilter={})).ALL="all",cd.OPERATOR="operator",cd.NONOPERATOR="nonoperator",e.QueryType=void 0,(ld=e.QueryType||(e.QueryType={})).AND="AND",ld.OR="OR",e.GroupChannelSearchField=void 0,(hd=e.GroupChannelSearchField||(e.GroupChannelSearchField={})).MEMBER_NICKNAME="member_nickname",hd.CHANNEL_NAME="channel_name";var pd,vd=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||!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,n=new t;this.searchFilter&&n.setSearchFilter(this.searchFilter.fields,null!==(e=this.searchFilter.query)&&void 0!==e?e:void 0),this.userIdsFilter&&n.setUserIdsFilter(this.userIdsFilter.userIds,this.userIdsFilter.includeMode,this.userIdsFilter.queryType);var r=JSON.parse(JSON.stringify(this));return Object.keys(r).forEach((function(e){n[e]=r[e]})),n}},{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}(),_d=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 Za(!!e).throw(A.databaseError),e.collection(go)}},{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 Ff.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(d&&d===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:(null==(u=t.sent)?void 0:u._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}(Ha);!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"}(pd||(pd={}));var md,gd=function(){function t(e){var n;r(this,t),this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=null!==(n=e.data)&&void 0!==n?n:{},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}(),yd={invitedUserIds:void 0,channelUrl:void 0,coverUrl:void 0,coverImage:void 0,isDistinct:void 0,isSuper:void 0,isBroadcast:void 0,isExclusive:void 0,isPublic:void 0,isDiscoverable:void 0,isStrict:void 0,isEphemeral:void 0,accessCode:void 0,name:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,messageSurvivalSeconds:void 0},kd=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,!0))&&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)},bd={customTypes:void 0,includeEmpty:!1,includeFrozen:!0},Ed=function(e){return F("string",e.customTypes,!0)&&L("boolean",e.includeEmpty)&&L("boolean",e.includeFrozen)},wd={myMemberStateFilter:e.MyMemberStateFilter.ALL},Cd=function(t){return D(e.MyMemberStateFilter,t.myMemberStateFilter)};e.UnreadItemKey=void 0,(md=e.UnreadItemKey||(e.UnreadItemKey={})).GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",md.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",md.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",md.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",md.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",md.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",md.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",md.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",md.SUPER_INVITATION_COUNT="super_group_channel_invitation_count";var xd,Td={keys:[]},Sd=function(t){return F(e.UnreadItemKey,t.keys)},Id={channelCustomTypesFilter:void 0,superChannelFilter:e.SuperChannelFilter.ALL},Nd=function(t){return F("string",t.channelCustomTypesFilter,!0)&&D(e.SuperChannelFilter,t.superChannelFilter)},Md={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:e.MessageTypeFilter.ALL},Ad=function(t){return L("string",t.channelUrl,!0)&&F(e.ScheduledStatus,t.scheduledStatus,!0)&&D(e.MessageTypeFilter,t.messageTypeFilter)},Od=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,g,k=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e instanceof du)){n.next=27;break}r=e.channels,a=e.source,u=e.isWebSocketEventComing,c=e.data,l=r.filter((function(e){return e instanceof Kp})),h=s.filterOffsetChanged(l),d=y(h),n.prev=5,d.s();case 7:if((f=d.n()).done){n.next=13;break}return p=f.value,n.next=11,i.removeUnderOffset(p.url,p.messageOffsetTimestamp);case 11:n.next=7;break;case 13:n.next=18;break;case 15:n.prev=15,n.t0=n.catch(5),d.e(n.t0);case 18:return n.prev=18,d.f(),n.finish(18);case 21:return n.next=23,s.upsert(l);case 23:v=n.sent,u||this._broadcastUpdateEvent(v,a,c),n.next=39;break;case 27:if(!(e instanceof fu)){n.next=36;break}return _=e.channelUrls,m=e.source,g=e.isWebSocketEventComing,n.next=31,s.remove(_);case 31:return n.next=33,xa((function(){return b(k,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(_),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:g||this._broadcastRemoveEvent(_,m),n.next=39;break;case 36:if(!(e instanceof cu)){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;){var s=r.value;s.onUpdate&&s.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;){var a=n.value;a.onRemove&&a.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}(),Ud=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._observers=new Map,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,C,x,T=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e instanceof ui)){n.next=14;break}if(r=e.messages,a=e.source,s=e.isWebSocketEventComing,u=r.filter((function(e){return e.messageId>0})),c=r.filter((function(e){return 0===e.messageId})),!(u.length>0)){n.next=8;break}return n.next=7,xa((function(){return b(T,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(u);case 2:return e.next=4,o.remove(u.map((function(e){return e instanceof Ms?e.reqId:null})).filter((function(e){return null!==e})));case 4:case"end":return e.stop()}}),e)})))}));case 7:s||this._broadcastUpdateEvent(u,a);case 8:if(!(c.length>0)){n.next=12;break}return n.next=11,xa((function(){return b(T,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(c);case 2:case"end":return e.stop()}}),e)})))}));case 11:s||this._broadcastUpdateEvent(c,a);case 12:n.next=61;break;case 14:if(!(e instanceof ci)){n.next=21;break}return l=e.messageIds,h=e.source,d=e.isWebSocketEventComing,n.next=18,xa((function(){return b(T,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(l);case 2:case"end":return e.stop()}}),e)})))}));case 18:d||this._broadcastRemoveEvent(l,h),n.next=61;break;case 21:if(!(e instanceof li)){n.next=28;break}return f=e.reqId,p=e.source,n.next=25,xa((function(){return b(T,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([f]);case 2:case"end":return e.stop()}}),e)})))}));case 25:this._broadcastRemoveUnsentEvent(f,p),n.next=61;break;case 28:if(!(e instanceof hi)){n.next=41;break}if(v=e.polls,_=e.source,!this._cacheContext.localCacheEnabled){n.next=38;break}return m=v.map((function(e){return e.messageId})),n.next=34,Promise.all(m.map((function(e){return i.get(e)})));case 34:return g=n.sent.filter((function(e){return e})),g.length>0&&v.forEach((function(e){var t=g.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),n.next=38,xa((function(){return b(T,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(g);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}));case 38:this._broadcastPollChangeLogEvent(v,_),n.next=61;break;case 41:if(!(e instanceof di)){n.next=52;break}return y=e.event,k=e.source,n.next=45,i.get(y.messageId);case 45:if(!((E=n.sent)&&E.isUserMessage()&&E.poll&&E.poll.applyPollUpdateEvent(y))){n.next=49;break}return n.next=49,xa((function(){return b(T,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([E]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}));case 49:this._broadcastPollUpdateEvent(y,k),n.next=61;break;case 52:if(!(e instanceof fi)){n.next=61;break}return w=e.event,C=e.source,n.next=56,i.get(w.messageId);case 56:if(!((x=n.sent)&&x.isUserMessage()&&x.poll&&x.poll.applyPollVoteEvent(w))){n.next=60;break}return n.next=60,xa((function(){return b(T,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([x]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}));case 60:this._broadcastPollVoteEvent(w,C);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;){var a=n.value;a.onUpdate&&a.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;){var a=n.value;a.onPollChangeLogUpdate&&a.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;){var a=n.value;a.onPollUpdate&&a.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;){var a=n.value;a.onPollVote&&a.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;){var a=n.value;a.onRemove&&a.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;){var a=n.value;a.onRemoveUnsent&&a.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}(),Rd=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({},bd),u),l=c.customTypes,h=c.includeEmpty,d=c.includeFrozen;return a.method=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/my_group_channels/changelogs"),a.params=ue(ce({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:i||null,token:o,custom_types:l,show_empty:h,show_frozen:d})),a}return s(n)}(Oe),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)).updatedChannels=a.updated.map((function(t){return new Kp(e,t)})),s.deletedChannelUrls=a.deleted,s.hasMore=a.has_more,s.token=a.next,s}return s(n)}(Ue),Dd=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=le.GET,a.path="".concat(i?ve:pe,"/").concat(encodeURIComponent(s)),a.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},a}return s(n)}(Oe),Pd=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 Kp(e,a),s}return s(n)}(Ue),Fd={includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,channelUrlsFilter:void 0,customTypesFilter:void 0,customTypeStartsWithFilter:void 0,nicknameContainsFilter:void 0,nicknameStartsWithFilter:void 0,nicknameExactMatchFilter:void 0,channelNameContainsFilter:void 0,myMemberStateFilter:e.MyMemberStateFilter.ALL,unreadChannelFilter:e.UnreadChannelFilter.ALL,superChannelFilter:e.SuperChannelFilter.ALL,publicChannelFilter:e.PublicChannelFilter.ALL,hiddenChannelFilter:e.HiddenChannelFilter.ALL,userIdsFilter:{userIds:[],includeMode:!0,queryType:e.QueryType.AND},searchFilter:{query:void 0,fields:[]},metadataKey:void 0,metadataValues:void 0,metadataOrderKeyFilter:void 0,metadataValueStartsWith:void 0,order:e.GroupChannelListOrder.LATEST_LAST_MESSAGE},Gd=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,C=e.metadataValues,x=e.metadataValueStartsWith,T=e.includeFrozen,S=e.includeMetaData,I=e.searchFilter,N=e.userIdsFilter;return(a=t.call(this)).method=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/my_group_channels"),a.params=ue({token:i,limit:o,order:null!=u?u:Fd.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=c?c:Fd.includeEmpty,member_state_filter:null!=l?l:Fd.myMemberStateFilter,super_mode:null!=h?h:Fd.superChannelFilter,public_mode:null!=d?d:Fd.publicChannelFilter,unread_filter:null!=f?f:Fd.unreadChannelFilter,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:C,metadata_value_startswith:x,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)}(Oe),qd=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).channels=[];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 Kp(e,t)}))),s.ts=null!=u?u:0,s}return s(n)}(Ue),Hd=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=le.GET,s.path="".concat(de,"/").concat(encodeURIComponent(i),"/group_channel_count"),s.params={state:null!=u?u:e.MyMemberStateFilter.ALL},s}return s(a)}(Oe),jd=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)}(Ue),zd=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=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/unread_item_count"),a.params=ue({item_keys:o}),a}return s(n)}(Oe),Vd=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)}(Ue),Bd=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=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/unread_channel_count"),a}return s(n)}(Oe),Qd=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)}(Ue),Kd=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=le.GET,s.path="".concat(de,"/").concat(encodeURIComponent(i),"/unread_message_count"),s.params={super_mode:null!=c?c:e.SuperChannelFilter.ALL,custom_types:u},s}return s(a)}(Oe),Wd=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)}(Ue),Yd=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=le.GET,a.path="".concat(we,"/count"),a.params={channel_url:s,status:Jd(i)},o&&(a.params.message_type=o),a}return s(n)}(Oe),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)).count=a.count,s}return s(n)}(Ue),Jd=function(t){if(!t)return[];var n=[];return t.forEach((function(t){switch(t){case e.ScheduledStatus.PENDING:n.push(ys.PENDING);break;case e.ScheduledStatus.SENT:n.push(ys.IN_QUEUE),n.push(ys.SENT);break;case e.ScheduledStatus.CANCELED:n.push(ys.CANCELED);break;case e.ScheduledStatus.FAILED:n.push(ys.FAILED)}})),n},Xd=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,C=e.operatorUserIds;return(a=t.call(this)).method=le.POST,a.path=pe,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:C,message_survival_seconds:E}),a}return s(n)}(Oe),$d=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)).channel=new Kp(e,a),s.isCreated=null===(i=a.is_created)||void 0===i||i,s}return s(n)}(Ue),ef=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=le.PUT,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/mark_as_read_all"),a.params={channel_urls:i},a}return s(n)}(Oe),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,"SYEV",s)).event=new gd(s),i}return s(n)}(qe),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.accessCode;return(a=t.call(this)).method=le.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(s),"/join"),a.params={user_id:i,access_code:o},a}return s(n)}(Oe),rf=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 Kp(e,a),s}return s(n)}(Ue),af=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?0:u,l=o.joined_member_count,h=void 0===l?0: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 dd(e,t)})):[new dd(e,s.data)],i}return s(n)}(tf),sf=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=le.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(s),"/leave"),a.params={user_id:i,should_remove_operator_status:o},a}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?0:u,l=o.joined_member_count,h=void 0===l?0:l;return i.memberCount=c,i.joinedMemberCount=h,i.member=new dd(i._iid,s.data),i}return s(n)}(tf),uf=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=le.POST,a.path="".concat(pe,"/").concat(encodeURIComponent(s),"/invite"),a.params={user_ids:i},a}return s(n)}(Oe),cf=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 Kp(e,a),s}return s(n)}(Ue),lf=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?0:u,l=o.joined_member_count,h=void 0===l?0:l,d=o.inviter,f=o.invitees,p=void 0===f?[]:f;return i.memberCount=c,i.joinedMemberCount=h,i.inviter=new Xa(e,d),i.invitees=p.map((function(t){return new dd(e,t)})),i}return s(n)}(tf),hf=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=le.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(s),"/decline"),a.params={user_id:i},a}return s(n)}(Oe),df=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=o.joined_member_count,l=o.inviter,h=o.invitee;return i.memberCount=null!=u?u:0,i.joinedMemberCount=null!=c?c:0,i.inviter=new Xa(e,l),i.invitee=new dd(e,h),i}return s(n)}(tf),ff=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)}(oa),pf=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 fd(e,s),i}return s(n)}(qe),vf=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=le.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(s),"/messages/mark_as_delivered"),a.params=ue({userId:i}),a}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,"DLVR",s)).channelUrl=s.channel_url,i.deliveredStateUpdate=s.updated,i}return s(n)}(qe),mf={hidePreviousMessages:!1,allowAutoUnhide:!0},gf=function(e){return L("boolean",e.hidePreviousMessages,!0)&&L("boolean",e.allowAutoUnhide,!0)},yf=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=le.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(s),"/hide"),a.params={user_id:i,hide_previous_messages:null!=o?o:mf.hidePreviousMessages,allow_auto_unhide:null!=u?u:mf.allowAutoUnhide},a}return s(n)}(Oe),kf=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.ts_message_offset;return s.messageOffsetTimestamp=i,s}return s(n)}(Ue),bf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c;return r(this,n),(i=t.call(this,e,"SYEV",s)).allowAutoUnhide=null,i.hidePreviousMessages=null,i.messageOffsetTimestamp=null,s.data&&(i.allowAutoUnhide=null!==(o=s.data.allow_auto_unhide)&&void 0!==o?o:null,i.hidePreviousMessages=null!==(u=s.data.hide_previous_messages)&&void 0!==u?u:null),i.messageOffsetTimestamp=null!==(c=s.ts_message_offset)&&void 0!==c?c:null,i}return s(n)}(qe),Ef=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)}(oa),wf=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 Xa(e,s.data),i}return s(n)}(qe),Cf=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)}(oa),xf=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 Xa(e,s.data),i}return s(n)}(qe),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.operators,u=void 0===o?[]:o;return i.operators=u.map((function(e){return new Xa(i._iid,e)})),i}return s(n)}(tf),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,"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)}(qe),If=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)}(oa),Nf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l;r(this,n),(i=t.call(this,e,"ADMM",s)).message=new Rs(e,s);var h=fs.of(e).sdkState;return i.isMentioned=Ie(i.message.mentionType,null!==(c=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})))&&void 0!==c?c:[],h.userId),i.forceUpdateLastMessage=null!==(l=s.force_update_last_message)&&void 0!==l&&l,i}return s(n)}(qe),Mf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l,h;r(this,n),(i=t.call(this,e,"AEDI",s)).message=new Rs(e,s);var d=fs.of(e).sdkState;return i.mentionCountChange=Ne({mentionType:null===(o=s.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=s.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},ce({mentionType:i.message.mentionType,mentionedUserIds:null!==(l=i.message.mentionedUserIds)&&void 0!==l?l:null===(h=i.message.mentionedUsers)||void 0===h?void 0:h.map((function(e){return e.userId}))}),d.userId),i}return s(n)}(qe),Af=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 ks(s),i}return s(n)}(qe),Of=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)}(qe),Uf=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=new ro(e,s),i.status=Ps(s.poll.status)||s.poll.status,i.channelUrl=s.channel_url,i.channelType=s.channel_type,i}return s(n)}(qe),Rf=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,C,x,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!==(C=n.metadataKey)&&void 0!==C?C:null,s.metadataValues=null!==(x=n.metadataValues)&&void 0!==x?x: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 Wa(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=Ff.of(this._iid),e.next=7,n.getMyGroupChannels(this._token,ce(Object.assign({},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}(Ii),Lf=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||H.unreadMentionCount>0)&&(H._updateUnreadCount(0,0),this._dispatcher.dispatch(new du({channels:[H],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),Ca((function(){return b(dn,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._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onChannelChanged&&a.onChannelChanged(H)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):0!==H.unreadMessageCount&&0!==H.unreadMentionCount||(this._dispatcher.dispatch(new du({channels:[H],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),Ca((function(){return b(dn,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._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onChannelChanged&&a.onChannelChanged(H)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):(this._dispatcher.dispatch(new du({channels:[H],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),Ca((function(){return b(dn,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._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onUnreadMemberStatusUpdated&&a.onUnreadMemberStatusUpdated(H)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))})));case 80:return a.abrupt("break",335);case 81:return j=n.as(_f),z=j.channelUrl,V=j.deliveredStateUpdate,B=void 0===V?{}:V,Q=this._groupChannelCache.isCachedInMemory(z),a.next=85,this.getChannel(z,!0);case 85:if(K=a.sent,Q)for(W in B)K._updateUndeliveredMemberState(W,B[W]);return Object.keys(B).some((function(e){return e!==dn._sdkState.userId}))&&(this._dispatcher.dispatch(new du({channels:[K],source:e.GroupChannelEventSource.EVENT_CHANNEL_DELIVERED})),Ca((function(){return b(dn,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._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onUndeliveredMemberStatusUpdated&&a.onUndeliveredMemberStatusUpdated(K)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",335);case 89:if(Y=n.as(Af),Z=Y.channelUrl,J=Y.channelType,X=Y.event,J!==e.ChannelType.GROUP){a.next=99;break}return a.next=93,this.getChannel(Z,!0);case 93:return $=a.sent,a.next=96,this.getMessageFromCache(X.messageId);case 96:(ee=a.sent)&&(ee.applyReactionEvent(X),this._dispatcher.dispatch(new ui({messages:[ee],source:e.MessageEventSource.EVENT_MESSAGE_REACTION_UPDATED}))),Ca((function(){return b(dn,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._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onReactionUpdated&&a.onReactionUpdated($,X)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 99:return a.abrupt("break",335);case 100:if(te=n.as(Of),(ne=te.event).channelType!==e.ChannelType.GROUP){a.next=110;break}return a.next=104,this.getChannel(ne.channelUrl,!0);case 104:return re=a.sent,a.next=107,this.getMessageFromCache(ne.targetMessageId);case 107:(ae=a.sent)&&(ae.applyThreadInfoUpdateEvent(ne),this._dispatcher.dispatch(new ui({messages:[ae],source:e.MessageEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))),Ca((function(){return b(dn,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._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onThreadInfoUpdated&&a.onThreadInfoUpdated(re,ne)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 110:return a.abrupt("break",335);case 111:se=n.as(Sf),ie=se.groupChannelMemberCounts,oe=[],ue=y(ie),a.prev=114,ue.s();case 116:if((ce=ue.n()).done){a.next=125;break}return le=ce.value,he=le.channelUrl,de=le.memberCount,fe=le.joinedMemberCount,pe=le.updatedAt,a.next=121,this.getChannelFromCache(he);case 121:(ve=a.sent)&&ve._setLatestMemberCount(de,fe,pe)&&oe.push(ve);case 123:a.next=116;break;case 125:a.next=130;break;case 127:a.prev=127,a.t2=a.catch(114),ue.e(a.t2);case 130:return a.prev=130,ue.f(),a.finish(130);case 133:return oe.length>0&&(this._dispatcher.dispatch(new du({channels:oe,source:e.GroupChannelEventSource.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),Ca((function(){return b(dn,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._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onChannelMemberCountChanged&&a.onChannelMemberCountChanged(oe)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",335);case 135:if(_e=n.as(Uf),me=_e.event,ge=_e.status,ye=_e.channelUrl,ke=_e.channelType,!ye||ke!==e.ChannelType.GROUP){a.next=142;break}return a.next=139,this.getChannel(ye,!0);case 139:be=a.sent,this._dispatcher.dispatch(new di({event:me,source:e.MessageEventSource.EVENT_POLL_UPDATED})),Ca(ge===Ds?function(){return b(dn,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._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onPollDeleted&&a.onPollDeleted(be,me.pollId)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return b(dn,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._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onPollUpdated&&a.onPollUpdated(be,me)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))});case 142:return a.abrupt("break",335);case 143:if(Ee=n.as(td),we=Ee.event,Ce=Ee.channelUrl,xe=Ee.channelType,!Ce||xe!==e.ChannelType.GROUP){a.next=150;break}return a.next=147,this.getChannel(Ce,!0);case 147:Te=a.sent,this._dispatcher.dispatch(new fi({event:we,source:e.MessageEventSource.EVENT_POLL_VOTED})),Ca((function(){return b(dn,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._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onPollVoted&&a.onPollVoted(Te,we)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 150:return a.abrupt("break",335);case 151:if(Se=n.as(tf),!(Ie=Se.event).isGroupChannelEvent){a.next=323;break}a.t3=Ie.category,a.next=a.t3===pd.CHANNEL_JOIN?156:a.t3===pd.CHANNEL_LEAVE?165:a.t3===pd.CHANNEL_OPERATOR_UPDATE?181:a.t3===pd.CHANNEL_INVITE?192:a.t3===pd.CHANNEL_DECLINE_INVITE?202:a.t3===pd.TYPING_START||a.t3===pd.TYPING_END?210:a.t3===pd.USER_CHANNEL_MUTE||a.t3===pd.USER_CHANNEL_UNMUTE?219:a.t3===pd.USER_CHANNEL_BAN?246:a.t3===pd.USER_CHANNEL_UNBAN?259:a.t3===pd.CHANNEL_FREEZE||a.t3===pd.CHANNEL_UNFREEZE?265:a.t3===pd.CHANNEL_HIDE?273:a.t3===pd.CHANNEL_UNHIDE?283:a.t3===pd.CHANNEL_DELETED?290:a.t3===pd.CHANNEL_PROP_CHANGED?296:a.t3===pd.CHANNEL_META_DATA_CHANGED?302:a.t3===pd.CHANNEL_META_COUNTERS_CHANGED?311:a.t3===pd.PINNED_MESSAGE_CHANGED?317:323;break;case 156:return a.next=158,this.getChannel(Ie.channelUrl,!0);case 158:return Ne=a.sent,Me=n.as(af),Ae=Me.memberCount,Oe=Me.joinedMemberCount,Ue=Me.members,Re=!1,Ue.forEach((function(t){Ne.isExclusive||Ne.isSuper||Ne.isBroadcast?Re=Re||Ne._setLatestMemberCount(Ae,Oe,Ie.ts):(t.state=e.MemberState.JOINED,Ne.addMember(t,Ie.ts),dn._updateJoinedMemberCount(Ne)),t.userId===dn._sdkState.userId&&(Ne.myMemberState=e.MemberState.JOINED)})),this._dispatcher.dispatch(new du({channels:[Ne],source:e.GroupChannelEventSource.EVENT_CHANNEL_JOINED})),Ca((function(){return b(dn,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(Ue);try{for(n.s();!(t=n.n()).done;){var r=t.value;e.onUserJoined&&e.onUserJoined(Ne,r)}}catch(e){n.e(e)}finally{n.f()}Ne.isBroadcast&&Re&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([Ne])}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 165:if(!(Le=this._leftChannels.get(Ie.channelUrl))){a.next=170;break}a.t4=Le.channel,a.next=173;break;case 170:return a.next=172,this.getChannel(Ie.channelUrl,!0);case 172:a.t4=a.sent;case 173:return De=a.t4,Pe=n.as(of),Fe=Pe.memberCount,Ge=Pe.joinedMemberCount,qe=Pe.member,He=!1,je=fs.of(this._iid),ze=je.appInfo,De.isExclusive||De.isSuper||De.isBroadcast?He=De._setLatestMemberCount(Fe,Ge,Ie.ts):((null==ze?void 0:ze.enabledChannelMemberShipHistory)?((Ve=De.members.find((function(e){return e.userId===Ve.userId})))&&(Ve.state=e.MemberState.LEFT),De.memberCount=Fe):De.removeMember(qe),this._updateJoinedMemberCount(De)),qe.userId===this._sdkState.userId?(De.myMemberState=e.MemberState.NONE,De.invitedAt=0,De.joinedAt=0,De._updateUnreadCount(0,0),De.isPublic?this._dispatcher.dispatch(new du({channels:[De],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})):(this._markAsLeave(De),this._dispatcher.dispatch(new fu({channelUrls:[De.url],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new du({channels:[De],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})),Ca((function(){return b(dn,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&&e.onUserLeft(De,qe),De.isBroadcast&&He&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([De])}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 181:return a.next=183,this.getChannel(Ie.channelUrl,!0);case 183:Be=a.sent,Qe=n.as(Tf),Ke=Qe.operators,We=Ke.map((function(e){return e.userId})),Ye=y(Be.members);try{for(Ye.s();!(Ze=Ye.n()).done;)(Je=Ze.value).role=We.includes(Je.userId)?e.Role.OPERATOR:e.Role.NONE}catch(e){Ye.e(e)}finally{Ye.f()}return Be.myRole=We.includes(this._sdkState.userId)?e.Role.OPERATOR:e.Role.NONE,this._dispatcher.dispatch(new du({channels:[Be],source:e.GroupChannelEventSource.EVENT_CHANNEL_OPERATOR_UPDATED})),Ca((function(){return b(dn,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&&e.onOperatorUpdated(Be,Ke)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 192:return a.next=194,this.getChannel(Ie.channelUrl,!0);case 194:Xe=a.sent,$e=n.as(lf),et=$e.memberCount,tt=$e.joinedMemberCount,nt=$e.inviter,(rt=$e.invitees).forEach((function(t){return t.state=e.MemberState.INVITED})),at=y(rt);try{for(at.s();!(st=at.n()).done;)it=st.value,Xe.isExclusive||Xe.isSuper||Xe.isBroadcast?Xe._setLatestMemberCount(et,tt,Ie.ts):Xe.addMember(it,Ie.ts),this._sdkState.userId===it.userId&&(Xe.hiddenState=e.HiddenState.UNHIDDEN,Xe.myMemberState!==e.MemberState.JOINED&&(Xe.myMemberState=e.MemberState.INVITED),Xe.invitedAt=Ie.ts)}catch(e){at.e(e)}finally{at.f()}return this._dispatcher.dispatch(new du({channels:[Xe],source:e.GroupChannelEventSource.EVENT_CHANNEL_INVITED})),Ca((function(){return b(dn,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&&e.onUserReceivedInvitation(Xe,nt,rt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 202:return a.next=204,this.getChannel(Ie.channelUrl,!0);case 204:return ot=a.sent,ut=n.as(df),ct=ut.memberCount,lt=ut.joinedMemberCount,ht=ut.inviter,dt=ut.invitee,ot.isExclusive||ot.isSuper||ot.isBroadcast?ot._setLatestMemberCount(ct,lt,Ie.ts):ot.removeMember(dt),this._sdkState.userId===dt.userId?(ot.invitedAt=0,ot.myMemberState=e.MemberState.NONE,ot.isPublic?this._dispatcher.dispatch(new du({channels:[ot],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new fu({channelUrls:[ot.url],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new du({channels:[ot],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE})),Ca((function(){return b(dn,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&&e.onUserDeclinedInvitation(ot,ht,dt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 210:return a.next=212,this.getChannel(Ie.channelUrl,!0);case 212:return ft=a.sent,pt=Ie.category===pd.TYPING_START,vt=n.as(pt?wf:xf),_t=vt.user,ft._updateTypingStatus(_t,pt?Ie.ts:0),this._dispatcher.dispatch(new du({channels:[ft],source:e.GroupChannelEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),Ca((function(){return b(dn,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&&e.onTypingStatusUpdated(ft)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 219:return a.next=221,this.getChannel(Ie.channelUrl,!0);case 221:mt=a.sent,gt=Ie.category===pd.USER_CHANNEL_MUTE,yt=n.as(gt?fh:vh),(kt=yt.user).userId===this._sdkState.userId&&(mt.myMutedState=gt?e.MutedState.MUTED:e.MutedState.UNMUTED,mt._myMutedRemainingTime=kt.restrictionInfo.remainingDuration),bt=y(mt.members),a.prev=226,bt.s();case 228:if((Et=bt.n()).done){a.next=235;break}if((wt=Et.value).userId!==kt.userId){a.next=233;break}return wt.isMuted=gt,a.abrupt("break",235);case 233:a.next=228;break;case 235:a.next=240;break;case 237:a.prev=237,a.t5=a.catch(226),bt.e(a.t5);case 240:return a.prev=240,bt.f(),a.finish(240);case 243:return this._dispatcher.dispatch(new du({channels:[mt],source:gt?e.GroupChannelEventSource.EVENT_CHANNEL_MUTED:e.GroupChannelEventSource.EVENT_CHANNEL_UNMUTED,data:kt.userId})),Ca((function(){return b(dn,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){gt?e.onUserMuted&&e.onUserMuted(mt,kt):e.onUserUnmuted&&e.onUserUnmuted(mt,kt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 246:if(!(Ct=this._leftChannels.get(Ie.channelUrl))){a.next=251;break}a.t6=Ct.channel,a.next=254;break;case 251:return a.next=253,this.getChannel(Ie.channelUrl,!0);case 253:a.t6=a.sent;case 254:return xt=a.t6,this._markAsLeave(xt),Tt=n.as(mh),St=Tt.user,Ca((function(){return b(dn,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&&e.onUserBanned(xt,St)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 259:return a.next=261,this.getChannel(Ie.channelUrl,!0);case 261:return It=a.sent,Nt=n.as(yh),Mt=Nt.user,Ca((function(){return b(dn,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&&e.onUserUnbanned(It,Mt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 265:return a.next=267,this.getChannel(Ie.channelUrl,!0);case 267:return At=a.sent,Ot=n.as(bh),Ut=Ot.freeze,At.isFrozen=Ut,this._dispatcher.dispatch(new du({channels:[At],source:Ut?e.GroupChannelEventSource.EVENT_CHANNEL_FROZEN:e.GroupChannelEventSource.EVENT_CHANNEL_UNFROZEN})),Ca((function(){return b(dn,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){Ut?e.onChannelFrozen&&e.onChannelFrozen(At):e.onChannelUnfrozen&&e.onChannelUnfrozen(At)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 273:return a.next=275,this.getChannel(Ie.channelUrl,!0);case 275:return Rt=a.sent,Lt=n.as(bf),Dt=Lt.allowAutoUnhide,Pt=Lt.hidePreviousMessages,Ft=Lt.messageOffsetTimestamp,null!==Dt&&(Rt.hiddenState=Dt?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Pt&&Pt&&Rt._updateUnreadCount(0,0),null!==Ft&&(Rt.messageOffsetTimestamp=Ft),this._dispatcher.dispatch(new du({channels:[Rt],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN})),Ca((function(){return b(dn,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&&e.onChannelHidden(Rt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 283:return a.next=285,this.getChannel(Ie.channelUrl,!0);case 285:return(Gt=a.sent).hiddenState=e.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new du({channels:[Gt],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN})),Ca((function(){return b(dn,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&&e.onChannelChanged(Gt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 290:return a.next=292,this.getChannel(Ie.channelUrl,!0);case 292:return qt=a.sent,this._dispatcher.dispatch(new fu({channelUrls:[Ie.channelUrl],source:e.GroupChannelEventSource.EVENT_CHANNEL_DELETED})),Ca((function(){return b(dn,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&&e.onChannelDeleted(qt.url,qt.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 296:return a.next=298,this.getChannelWithoutCache(Ie.channelUrl,!0);case 298:return Ht=a.sent,this._dispatcher.dispatch(new du({channels:[Ht],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),Ca((function(){return b(dn,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&&e.onChannelChanged(Ht)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 302:return a.next=304,this.getChannel(Ie.channelUrl,!0);case 304:return jt=a.sent,zt=n.as(Xl),Vt=zt.created,Bt=zt.updated,Qt=zt.deleted,Vt&&jt._upsertCachedMetaData(Vt,Ie.ts),Bt&&jt._upsertCachedMetaData(Bt,Ie.ts),Qt&&jt._removeFromCachedMetaData(Qt,Ie.ts),Ca((function(){return b(dn,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.onMetaDataCreated&&e.onMetaDataCreated(jt,Vt),Bt&&e.onMetaDataUpdated&&e.onMetaDataUpdated(jt,Bt),Qt&&e.onMetaDataDeleted&&e.onMetaDataDeleted(jt,Qt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 311:return a.next=313,this.getChannel(Ie.channelUrl,!0);case 313:return Kt=a.sent,Wt=n.as(ch),Yt=Wt.created,Zt=Wt.updated,Jt=Wt.deleted,Ca((function(){return b(dn,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){Yt&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Kt,Yt),Zt&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Kt,Zt),Jt&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Kt,Jt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",323);case 317:return a.next=319,this.getChannel(Ie.channelUrl,!0);case 319:return Xt=a.sent,$t=n.as(Df),en=$t.pinnedMessageIds,tn=$t.latestPinnedMessage,(nn=$t.ts)>Xt._pinnedMessagesUpdatedAt&&(Xt.pinnedMessageIds=en,Xt.lastPinnedMessage=tn,Xt._pinnedMessagesUpdatedAt=nn,this._dispatcher.dispatch(new du({channels:[Xt],source:e.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED})),Ca((function(){return b(dn,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._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onChannelChanged&&a.onChannelChanged(Xt)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))})),Ca((function(){return b(dn,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&&e.onPinnedMessageUpdated(Xt)}));case 1:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",323);case 323:return a.abrupt("break",335);case 324:rn=n.as(vu),an=rn.event,a.t7=an.category,a.next=a.t7===jo.USER_BLOCK?328:a.t7===jo.USER_UNBLOCK?331:334;break;case 328:return sn=uu.getDataAsUserBlockEvent(this._iid,an),on=sn.blocker,un=sn.blockee,this._groupChannelCache.block(on.userId,un.userId),a.abrupt("break",334);case 331:return cn=uu.getDataAsUserBlockEvent(this._iid,an),ln=cn.blocker,hn=cn.blockee,this._groupChannelCache.unblock(ln.userId,hn.userId),a.abrupt("break",334);case 334:return a.abrupt("break",335);case 335:a.next=341;break;case 337:if(a.prev=337,a.t8=a.catch(0),!M(a.t8)){a.next=341;break}throw a.t8;case 341:case"end":return a.stop()}}),a,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 Za(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 Za(L("string",n)).throw(A.invalidParameters),s=new Dd({channelUrl:n,isInternalCall:r}),t.next=4,this._requestQueue.send(s);case 4:i=t.sent,o=i.as(Pd),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 Dd({channelUrl:n,isInternalCall:r}),t.next=4,this._requestQueue.send(i);case 4:if(o=t.sent,u=o.as(Pd),(c=u.channel).myMemberState!==e.MemberState.NONE){t.next=10;break}this._dispatcher.dispatch(new fu({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 du({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 fu({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 Gd(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(qd),c=u.channels,l=u.token,this._dispatcher.dispatch(new du({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){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.next=2,this._messageCache.get(e);case 2:if(t.t1=n=t.sent,t.t0=null!==t.t1,!t.t0){t.next=6;break}t.t0=void 0!==n;case 6:if(!t.t0){t.next=10;break}t.t2=n,t.next=11;break;case 10:t.t2=null;case 11:return t.abrupt("return",t.t2);case 12:case"end":return t.stop()}}),r,this)})))}},{key:"getMessagesFromCache",value:function(e,n,r,a){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:yo;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]:yo;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 Lf({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({},bd),r),Za((L("string",n)||L("number",n))&&Ed(s)).throw(A.invalidParameters),i=new Rd(ce({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(Ld),c=u.updatedChannels,l=u.deletedChannelUrls,h=u.hasMore,c.length>0&&this._dispatcher.dispatch(new du({channels:c,source:a})),l.length>0&&this._dispatcher.dispatch(new fu({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({},wd),e),Za(Cd(r)).throw(A.invalidParameters),a=new Hd({userId:this._sdkState.userId,filter:r}),t.next=5,this._requestQueue.send(a);case 5:return s=t.sent,i=s.as(jd),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({},Td),e),Za(Sd(r)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new zd({userId:s.userId,filter:r}),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Vd),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=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Bd({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Qd),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({},Id),e),Za(Nd(r)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Kd({userId:s.userId,filter:r}),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Wd),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({},Md),e),Za(Ad(r)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.requestQueue,i=new Yd(r),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(Zd),c=u.count,t.abrupt("return",c);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){var e=fs.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){var e=0,t=fs.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=fs.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({},yd),e),Za(kd(r)).throw(A.invalidParameters),r.isPublic||(r.accessCode=void 0),a=new Xd(Object.assign({userId:this._sdkState.userId},r)),t.next=6,this._requestQueue.send(a);case 6:return s=t.sent,i=s.as($d),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(),Za(n-this._markAsReadAllLastSentAt>=1e3).throw(A.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=n,r=new ef({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(),Za(F("string",e)&&r-this._markAsReadAllLastSentAt>=1e3).throw(A.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=r,a=new ef({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 Pf[e]}},{key:"clear",value:function(e){Pf[e]&&delete Pf[e]}}]),n}();!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(xd||(xd={}));var Gf=function(e){i(a,e);var n=f(a);function a(e,t){var s;return r(this,a),(s=n.call(this))._state=xd.IDLE,s._retryCount=0,s._retryLimit=3,s.priority=0,s._worker=t,s}return s(a,[{key:"isIdle",get:function(){return this._state===xd.IDLE}},{key:"isRunning",get:function(){return this._state===xd.RUNNING}},{key:"isDone",get:function(){return this._state===xd.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&&(f=h.map((function(e){return e.createdAt})),(null===(u=this._metadata)||void 0===u?void 0:(d=u.range).intersect.apply(d,_(f)))?this.extendRange(h):this._metadata={range:new Lf({top:Math.min.apply(Math,_(f)),bottom:Math.max.apply(Math,_(f))}),previousComplete:!1}),c.hasNext=h.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(c.nextToken=this._metadata.range.top,this._metadata.previousComplete=h.length0&&(d=l.map((function(e){return e.createdAt})),(null===(o=this._metadata)||void 0===o?void 0:(h=o.range).intersect.apply(h,_(d)))?this.extendRange(l):this._metadata={range:new Lf({top:Math.min.apply(Math,_(d)),bottom:Math.max.apply(Math,_(d))}),previousComplete:!1}),u.hasNext=l.length>=this._limit&&this._nextSyncLoopCount<1,this._metadata&&(u.nextToken=this._metadata.range.bottom),v.debug("message background next sync progress",u),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",u);case 23:case"end":return t.stop()}}),r,this,[[5,18]])})))})),this._connectionEventContext=p.on((function(e){if(e instanceof da)if(e.stateType===sa.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"range",get:function(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new Lf({})}},{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=fs.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=fs.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(){fs.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 jf[this._iid][this._channel.url])}}],[{key:"of",value:function(e,t){return jf[e]||(jf[e]={}),jf[e][t.url]||(jf[e][t.url]=new n({_iid:e,channel:t})),jf[e][t.url].ref++,jf[e][t.url]}},{key:"clear",value:function(e,t){jf[e]&&jf[e][t]&&(jf[e][t].close(),delete jf[e])}}]),n}(),Vf={},Bf=function(){function n(a){var s=this,i=a._iid,o=a.channel;r(this,n),this.ref=0,this._iid=i,this._channel=o;var u,c,l=fs.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 Gf(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=wi.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&&(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 da)if(e.stateType===sa.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=fs.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=fs.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=fs.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){var e=fs.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=fs.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 Vf[this._iid][this._channel.url])}}],[{key:"of",value:function(e,t){return Vf[e]||(Vf[e]={}),Vf[e][t.url]||(Vf[e][t.url]=new n({_iid:e,channel:t})),Vf[e][t.url].ref++,Vf[e][t.url]}},{key:"clear",value:function(e,t){Vf[e]&&Vf[e][t]&&(Vf[e][t].close(),delete Vf[e])}}]),n}(),Qf={},Kf=function(){function e(n){var a=this,s=n._iid,i=n.channel,o=n.hasPollMessage;r(this,e),this.ref=0,this._iid=s,this._channel=i;var u,c,l=fs.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 Gf(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=fs.of(this._iid),i=s.firstConnectedAt,this._metadata={token:i}),e.prev=13,u=no.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 da)if(e.stateType===sa.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=fs.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}:void 0;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=fs.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=fs.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){fs.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)}},{key:"pause",value:function(){fs.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 Qf[this._iid][this._channel.url])}}],[{key:"of",value:function(t,n,r){return Qf[t]||(Qf[t]={}),Qf[t][n.url]||(Qf[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r})),Qf[t][n.url].ref++,Qf[t][n.url]}}]),e}(),Wf=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=le.GET,a.path="".concat(Te(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)}(Oe),Yf=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 Bs(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 Bs(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)}(Ue),Zf=function(t,n){var r,a,s,i;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;default:return null!==(i=null===(s=t.lastMessage)||void 0===s?void 0:s.createdAt)&&void 0!==i?i:t.createdAt}},Jf=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},Xf=function(e,t,n){if(e.length>0){for(var r=Jf(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:$f(e[i],t,n)>=0?i:i+1,oldPosition:r}}return{place:e.length,oldPosition:-1}},$f=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;default:return 0}},ep=function(e,t){return t instanceof Ms?e.findIndex((function(e){return e instanceof Ms&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},tp=function(e,t){return e.findIndex((function(e){return e.messageId===t}))},np=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},rp=6e5;e.MessageCollectionInitPolicy=void 0,(e.MessageCollectionInitPolicy||(e.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";var ap,sp,ip,op=function(){function e(){r(this,e)}return s(e,[{key:"_invokeResponse",value:function(e,n,r){var a=this;Ca((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}(),up=function(){function n(a,s){var i=this,o=s.channel,u=s.filter,c=s.startingPoint,l=s.limit;r(this,n),this._messages=[],this._unsentMessages=[],this._iid=a,this._key="mc-".concat(re()),this.filter=null!=u?u:new wo,this._channel=o,this._syncRange=new Lf({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof c?c:Date.now()+rp,this._limit=l||yo;var h=Ff.of(this._iid);h.subscribeGroupChannelEvent(this._key,{onUpdate:function(n,r,a){var s=Jf(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;fs.of(i._iid).sdkState.userId===h&&i._clearCheckMyMutedTimer();break;case e.GroupChannelEventSource.EVENT_CHANNEL_MUTED:var d=a;fs.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()}Ca((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 qf(r),hu(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(),Ca((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 qf(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(oi(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=fs.of(this._iid),f=d.cacheContext,p=d.dispatcher,v=d.logger;this._channel._updateMessageCollectionLastAccessedAt(),p.dispatch(new du({channels:[this._channel],source:e.GroupChannelEventSource.CHANNEL_LASTACCESSEDAT_UPDATED})),!this._channel.isSuper&&f.localCacheEnabled&&(this._backgroundSync=zf.of(this._iid,this._channel),this._backgroundSync.resume(this._startingPoint)),this._changelogSync=Bf.of(this._iid,this._channel),this._changelogSync.resume(),this._pollChangelogSync=Kf.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new Gf(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 da)switch(n.stateType){case sa.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 sa.LOGOUT:i.dispose();break;default:i._clearCheckMyMutedTimer(),i._prevFill.stop(),i._nextFill.stop()}})),fs.of(this._iid).statLogCollector.put(new ss({type:Ae.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(ep(this._messages,l)<0){ep(this._unsentMessages,l)<0&&o.push(l);var h=np(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof Ms){ep(this._unsentMessages,l)<0&&ep(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l))}}else if(l.messageId>0){var d=ep(this._messages,l);if(d<0){var f=ep(this._unsentMessages,l);f<0?o.push(l):(this._unsentMessages.splice(f,1),u.push(l));var p=np(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 Ms){var m=ep(this._unsentMessages,l);m<0?ep(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()}oi(r)&&Ca((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 Hf(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=tp(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&&oi(n)&&Ca((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 Hf(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=tp(this._messages,e.messageId);if(a>=0){var s=this._messages[a];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollUpdateEvent(e)&&oi(n)&&Ca((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 Hf(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=tp(this._messages,e.messageId);if(a>=0){var s=this._messages[a];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollVoteEvent(e)&&oi(n)&&Ca((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 Hf(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=ep(this._messages,u);if(c>=0)s.push(u),this._messages[c]=u;else{var l=ep(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=np(this._messages,u);this._messages.splice(d,0,u)}}}}else if(u instanceof Ms){var f=ep(this._unsentMessages,u);f>=0&&(s.push(u),this._unsentMessages[f]=u)}}}catch(e){o.e(e)}finally{o.f()}return oi(n)&&Ca((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 Hf(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 oi(n)&&i.length>0&&Ca((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 Hf(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=Ff.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=wi.of(this._iid),!(s>0||o>0)){e.next=7;break}return e.next=4,r._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,n,ce(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,C,x,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=Ff.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,wa((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,C,x,T,S,I,N,M,A,O=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return u=fs.of(this._iid),h=u.dispatcher,d=u.requestQueue,f=u.cacheContext,p=new Wf(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(Yf),g=m.isHugeGap,y=m.prevMessages,k=void 0===y?[]:y,E=m.prevHasMore,w=m.isContinuousPrevMessages,C=m.nextMessages,x=void 0===C?[]:C,T=m.nextHasmore,S=m.isContinuousNextMessages,g?Ca((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(_(x.map((function(e){return e.createdAt}))))),h.dispatch(new ui({messages:k,source:e.MessageEventSource.SYNC_MESSAGE_FILL})),h.dispatch(new ui({messages:x,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=fs.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,C=0,x=0;x=p&&C++;this._hasPrevious=w>=f,this._hasNext=C>=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=Ff.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=Ff.of(this._iid),e.next=3,n.getPollMessagesFromCache(this._channel.url,Date.now()+rp,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){Ff.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=void 0,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 qf(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=void 0)}},{key:"initialize",value:function(n){var r=this,a=new op;this._messages=[],this._unsentMessages=[],this._syncRange=new Lf({}),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=fs.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=fs.of(this._iid),o=i.cacheContext;return i.statLogCollector.put(new ss({type:Ae.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=fs.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=fs.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=Ff.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=fs.of(this._iid),s=a.cacheContext,i=a.dispatcher;this._clearCheckMyMutedTimer(),this._channel._updateMessageCollectionLastAccessedAt(),i.dispatch(new du({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=Ff.of(this._iid);o.unsubscribeGroupChannelEvent(this._key),o.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}}]),n}(),cp={coverUrl:void 0,coverImage:void 0,isDistinct:void 0,isPublic:void 0,isDiscoverable:void 0,accessCode:void 0,name:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,messageSurvivalSeconds:void 0},lp=function(e){return L("string",e.coverUrl,!0)&&(q(e.coverImage)||L("string",e.coverImage,!0))&&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)},hp=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=le.GET,a.path="".concat(pe,"/").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)}(Oe),dp=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).members=[];var i=a.next,o=a.members;return s.token=i,o&&o.length>0&&(s.members=o.map((function(t){return new dd(e,t)}))),s}return s(n)}(Ue);e.MutedMemberFilter=void 0,(ap=e.MutedMemberFilter||(e.MutedMemberFilter={})).ALL="all",ap.MUTED="muted",ap.UNMUTED="unmuted",e.MemberListOrder=void 0,(sp=e.MemberListOrder||(e.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",sp.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",e.MemberStateFilter=void 0,(ip=e.MemberStateFilter||(e.MemberStateFilter={})).ALL="all",ip.JOINED="joined_only",ip.INVITED="invited_only",ip.INVITED_BY_FRIEND="invited_by_friend",ip.INVITED_BY_NON_FRIEND="invited_by_non_friend";var fp,pp,vp,_p=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=fs.of(this._iid),r=n.requestQueue,a=new hp(ce(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(dp),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}(Li),mp=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=le.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(s),"/accept"),a.params={user_id:i,access_code:o},a}return s(n)}(Oe),gp=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 Kp(t,s),i.channel.myMemberState=e.MemberState.JOINED,i}return s(a)}(Ue),yp=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=le.PUT,a.path="".concat(pe,"/").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)}(Oe),kp=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 Kp(e,a),s}return s(n)}(Ue),bp=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=le.DELETE,a.path="".concat(pe,"/").concat(encodeURIComponent(s)),a}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=le.DELETE,a.path="".concat(pe,"/").concat(encodeURIComponent(s),"/hide"),a}return s(n)}(Oe),wp=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=le.PUT,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/count_preference/").concat(encodeURIComponent(i)),a.params={count_preference:o},a}return s(n)}(Oe),Cp=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)}(Ue),xp=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=le.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(s),"/reset_user_history"),a}return s(n)}(Oe),Tp=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.ts_message_offset;return s.messageOffsetTimestamp=i,s}return s(n)}(Ue),Sp=Object.assign(Object.assign({},xl),{scheduledAt:void 0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Ip=function(e){return Tl(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})))},Np=Object.assign(Object.assign({},Sl),{scheduledAt:void 0}),Mp=function(e){return Il(e)&&L("number",e.scheduledAt,!0)},Ap=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,l=t.scheduledMessageId;return s.method=le.PUT,s.path="".concat(Te(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),s.params=ue(ce({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 As.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 Es.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?xs.payloadify(t.appleCriticalAlertOptions):null,push_option:t.pushNotificationDeliveryOption})),s}return s(a)}(Oe),Op=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)}(Ue),Up=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,l=t.scheduledMessageId;return s.method=le.PUT,s.path="".concat(Te(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),s.params=ue(ce({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 Es.payloadify(e)})),apple_critical_alert_options:t.appleCriticalAlertOptions?xs.payloadify(t.appleCriticalAlertOptions):null,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption})),s}return s(a)}(Oe),Rp=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=le.DELETE,a.path="".concat(Te(s),"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(o)),a}return s(n)}(Oe),Lp=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=le.POST,a.path="".concat(Te(s),"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(o),"/send_now"),a}return s(n)}(Oe),Dp=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=le.PUT,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push_preference/").concat(encodeURIComponent(i)),a.params={push_trigger_option:o},a}return s(n)}(Oe),Pp=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)}(Ue),Fp=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=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push_preference/").concat(encodeURIComponent(i)),a}return s(n)}(Oe),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,a)).pushTriggerOption=a.push_trigger_option,s.enabled=a.enable,s}return s(n)}(Ue),qp=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=le.POST,a.path="".concat(Te(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/pin"),a}return s(n)}(Oe),Hp=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=le.DELETE,a.path="".concat(Te(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/pin"),a}return s(n)}(Oe),jp=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=Bs(e,a.message),s}return s(n)}(Ha),zp=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=le.GET,a.path="".concat(Te(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)}(Oe),Vp=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.pinned_messages,o=a.has_more,u=a.next;return s.pinnedMessages=i.map((function(t){return new jp(e,t)})),s.hasMore=o,s.token=u,s}return s(n)}(Ue),Bp=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=fs.of(this._iid),r=n.requestQueue,a=new zp(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Vp),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}(Li);e.CountPreference=void 0,(fp=e.CountPreference||(e.CountPreference={})).ALL="all",fp.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",fp.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",fp.OFF="off",e.MutedState=void 0,(pp=e.MutedState||(e.MutedState={})).MUTED="muted",pp.UNMUTED="unmuted",e.HiddenState=void 0,(vp=e.HiddenState||(e.HiddenState={})).UNHIDDEN="unhidden",vp.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",vp.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";var Qp,Kp=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,C,x,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 dd(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?Bs(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 Xa(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!==(C=n.unread_mention_count)&&void 0!==C?C:0),s.pinnedMessageIds=null!==(x=n.pinned_message_ids)&&void 0!==x?x:[],s.lastPinnedMessage=n.latest_pinned_message?Bs(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 Ms&&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=fs.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=fs.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return!!n&&n>=e.createdAt}},{key:"serialize",value:function(){var e=this;return Wa(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 up(this._iid,Object.assign({channel:this},e))}},{key:"createMemberListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new _p(this._iid,this.url,e)}},{key:"createPinnedMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Bp(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 dd?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 Ms&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var n,r=fs.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=fs.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof Ms?e.sender:null,s=[];return this.members.forEach((function(i){if(n||i.userId!==r.userId&&i.userId!==(null==a?void 0:a.userId)){var o=t._unreadMemberStateMap.get(i.userId);o&&o>=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=fs.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof Ms?e.sender:null,s=[];return this.members.forEach((function(i){if(n||i.userId!==r.userId&&i.userId!==(null==a?void 0:a.userId)){var o=t._unreadMemberStateMap.get(i.userId);o&&o0&&void 0!==arguments[0]&&arguments[0],n=fs.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 fd(e._iid,{channel_url:e.url,channel_type:e.channelType,user:dd.payloadify(a),ts:null!=s?s:0})}})),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=fs.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=fs.of(this._iid),a=r.requestQueue,s=r.dispatcher,i=new Dd({channelUrl:this.url}),t.next=4,a.send(i);case 4:return o=t.sent,u=o.as(Pd),c=u.channel,this._update(c),s.dispatch(new du({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=fs.of(this._iid),a.dispatcher.dispatch(new du({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_FROZEN,isWebSocketEventComing:!0}));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=fs.of(this._iid),a.dispatcher.dispatch(new du({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNFROZEN,isWebSocketEventComing:!0}));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({},cp),n),Za(lp(a)).throw(A.invalidParameters),s=fs.of(this._iid),i=s.dispatcher,o=s.requestQueue,u=new yp(Object.assign({channelUrl:this.url},a)),t.next=6,o.send(u);case 6:return c=t.sent,l=c.as(kp),h=l.channel,this._update(h),i.dispatch(new du({channels:[h],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),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 Za(e.every((function(e){return e instanceof Xa}))).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 Za(F("string",n)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.dispatcher,i=a.requestQueue,o=new uf({channelUrl:this.url,userIds:n}),t.next=5,i.send(o);case 5:return u=t.sent,c=u.as(cf),l=c.channel,this._update(l),s.dispatch(new du({channels:[l],source:e.GroupChannelEventSource.EVENT_CHANNEL_INVITED,isWebSocketEventComing:!0})),t.abrupt("return",this);case 10:case"end":return t.stop()}}),r,this)})))}},{key:"join",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 Za(L("string",n,!0)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new nf({channelUrl:this.url,userId:i.userId,accessCode:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(rf),(h=l.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,this._update(h),s.dispatch(new du({channels:[h],source:e.GroupChannelEventSource.EVENT_CHANNEL_JOINED,isWebSocketEventComing:!0})),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=fs.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new sf({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(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 Za(L("string",n,!0)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new mp({channelUrl:this.url,userId:i.userId,accessCode:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(gp),(h=l.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,this._update(h),s.dispatch(new du({channels:[h],source:e.GroupChannelEventSource.EVENT_CHANNEL_ACCEPTED_INVITE,isWebSocketEventComing:!0})),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=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new hf({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 Ci,a=fs.of(this._iid).dispatcher,s=iu.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),Ff.of(n._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),a.dispatch(new du({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=fs.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&&(Ff.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(h)})),o.dispatch(new du({channels:[this],source:l?e.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.GroupChannelEventSource.EVENT_MESSAGE_UPDATED}))),l&&Ff.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(h)})),o.dispatch(new ui({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 Ci,a=fs.of(this._iid).dispatcher,s=iu.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=Ff.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),i.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),a.dispatch(new du({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"sendFileMessage",value:function(t){var n=this,r=new Ci,a=fs.of(this._iid).dispatcher,s=iu.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=Ff.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),i.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),a.dispatch(new du({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(null,t)})),r}},{key:"sendMultipleFilesMessage",value:function(t){var n=this,r=new Gi,a=fs.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=Ff.of(n._iid);n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),s.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),a.dispatch(new du({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=fs.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&&(Ff.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(h)})),o.dispatch(new du({channels:[this],source:l?e.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.GroupChannelEventSource.EVENT_MESSAGE_UPDATED}))),l&&Ff.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(h)})),o.dispatch(new ui({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 Ci,a=fs.of(this._iid).dispatcher,s=iu.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=Ff.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),i.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),a.dispatch(new du({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 Ms&&(s=fs.of(this._iid),s.dispatcher.dispatch(new li({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({},mf),n),Za(gf(a)).throw(A.invalidParameters),s=fs.of(this._iid),i=s.dispatcher,o=s.sdkState,u=s.requestQueue,c=new yf(Object.assign({channelUrl:this.url,userId:o.userId},a)),t.next=6,u.send(c);case 6:return l=t.sent,h=l.as(kf),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 du({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN,isWebSocketEventComing:!0})),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=fs.of(this._iid),a=r.dispatcher,s=r.requestQueue,i=new Ep({channelUrl:this.url}),t.next=4,s.send(i);case 4:return this.hiddenState=e.HiddenState.UNHIDDEN,a.dispatch(new du({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN,isWebSocketEventComing:!0})),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=fs.of(this._iid),r=n.requestQueue,a=new bp({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=fs.of(this._iid),a=r.sdkState,s=r.dispatcher,i=r.requestQueue,o=new ff({channelUrl:this.url}),t.next=4,i.send(o);case 4:u=t.sent,c=u.as(pf),l=c.readStatus,this._updateUnreadMemberState(a.userId,l.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),Ff.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(h)}))),s.dispatch(new du({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=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new vf({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=fs.of(this._iid),r=n.requestQueue,a=n.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingStarted>=a&&(this._typingStarted=s,this._typingEnded=0,i=new Ef({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=fs.of(this._iid),r=n.requestQueue,a=n.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingEnded>=a&&(this._typingStarted=0,this._typingEnded=s,i=new Cf({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({},Bo),e),Za(function(e){return Ao(e)&&L("number",e.scheduledAt,!0)}(e)).throw(A.invalidParameters);var t=new Ci;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({},Np),n),Za(Mp(a)).throw(A.invalidParameters),s=fs.of(this._iid),i=s.requestQueue,o=new Up(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(qh),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({},Qo),e),Za(function(e){return So(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 Ci;return ba(2).then((function(){var i=n._createPendingScheduledFileMessage(e,a,r);Ca((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({},Sp),n),Za(Ip(a)).throw(A.invalidParameters),!q(a.file)){t.next=5;break}return t.next=5,this._uploadFileAndUpdateParams(a);case 5:return s=new Ap(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},a)),i=fs.of(this._iid),o=i.requestQueue,t.next=9,o.send(s);case 9:return u=t.sent,c=u.as(Op),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 Rp({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),a=fs.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 Lp({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),a=fs.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=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Fp({userId:r.userId,channelUrl:this.url}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Gp),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 Za(D(e.PushTriggerOption,n)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new Dp({userId:i.userId,channelUrl:this.url,pushTriggerOption:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(Pp),h=l.pushTriggerOption,this.myPushTriggerOption=h,s.dispatch(new du({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),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 Za(D(e.CountPreference,n)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new wp({channelUrl:this.url,userId:i.userId,countPreference:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(Cp),h=l.countPreference,this.myCountPreference=h,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),s.dispatch(new du({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),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=fs.of(this._iid),a=r.dispatcher,s=r.requestQueue,i=new xp({channelUrl:this.url}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(Tp),c=u.messageOffsetTimestamp,this.messageOffsetTimestamp=c,a.dispatch(new du({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_RESET_HISTORY,isWebSocketEventComing:!0})),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 Za(L("number",e)&&e>0).throw(A.invalidParameters),r=fs.of(this._iid),a=r.requestQueue,s=new qp({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 Za(L("number",e)&&e>0).throw(A.invalidParameters),r=fs.of(this._iid),a=r.requestQueue,s=new Hp({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=fs.of(this._iid),a=r.requestQueue,s=new vs({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(_s),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 ue(ce(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 dd.payloadify(e)})),last_message:e.lastMessage?Vs(e.lastMessage):null,inviter:e.inviter?Xa.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,pinned_message_ids:e.pinnedMessageIds,latest_pinned_message:e.lastPinnedMessage?Vs(e.lastPinnedMessage):null})))}}]),u}(nd),Wp={},Yp=function(){function n(a){var s=this,i=a._iid,o=a.limit,u=void 0===o?100:o;r(this,n),this.ref=0,this._iid=i,this._limit=u;var c,l=fs.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 Gf(p,(function(){return b(s,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 o={hasNext:!0,nextToken:""},t.next=3,this.loadMetadata();case 3:if(f.debug("channel background sync from",null===(r=this._metadata)||void 0===r?void 0:r.token),null===(a=this._metadata)||void 0===a?void 0:a.completed){t.next=29;break}return t.prev=5,u=Ff.of(this._iid),t.next=9,u.getMyGroupChannels(null!==(i=null===(s=this._metadata)||void 0===s?void 0:s.token)&&void 0!==i?i:"",{includeEmpty:!0,order:e.GroupChannelListOrder.CHRONOLOGICAL},this._limit,e.GroupChannelEventSource.SYNC_CHANNEL_BACKGROUND);case 9:return c=t.sent,l=c.channels,h=c.token,o.hasNext=l.length>=this._limit&&!!h,o.nextToken=h,this._metadata&&(this._metadata.token=h,(d=this._metadata.range).extends.apply(d,_(l.map((function(e){return e.createdAt})))),this._metadata.completed=!o.hasNext),f.debug("channel background sync progress",o),t.next=18,this.saveMetadata();case 18:t.next=27;break;case 20:if(t.prev=20,t.t0=t.catch(5),f.debug("channel background sync error",t.t0),!(t.t0 instanceof A&&t.t0.isInvalidTokenError)){t.next=26;break}return t.next=26,this.clearMetaData();case 26:throw t.t0;case 27:t.next=31;break;case 29:o.hasNext=!1,o.nextToken="";case 31:return t.abrupt("return",o);case 32:case"end":return t.stop()}}),n,this,[[5,20]])})))})),this._connectionEventContext=d.on((function(e){if(e instanceof da)if(e.stateType===sa.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"range",get:function(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new Lf({})}},{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=fs.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 Lf(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=fs.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=fs.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){var e,t,n=fs.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(){fs.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 Wp[this._iid])}}],[{key:"of",value:function(e){return Wp[e]||(Wp[e]=new n({_iid:e})),Wp[e].ref++,Wp[e]}},{key:"clear",value:function(e){Wp[e]&&(Wp[e].close(),delete Wp[e])}}]),n}(),Zp={},Jp=function(){function n(a){var s=this,i=a._iid;r(this,n),this.ref=0,this._iid=i;var o,u=fs.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 Gf(d,(function(){return b(s,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i={hasNext:!0,nextToken:0},t.next=3,this.loadMetadata();case 3:return c.debug("channel changelog sync from",null===(r=this._metadata)||void 0===r?void 0:r.token),t.prev=4,o=Ff.of(this._iid),t.next=8,o.getMyGroupChannelChangeLogs(null!==(s=null===(a=this._metadata)||void 0===a?void 0:a.token)&&void 0!==s?s:"",{includeEmpty:!0},e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS);case 8:return u=t.sent,l=u.hasMore,h=u.token,i.hasNext=l,i.nextToken=h,this._metadata&&(this._metadata.token=h),c.debug("channel changelog sync progress",i),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",i);case 27:case"end":return t.stop()}}),n,this,[[4,19]])})))})),this._connectionEventContext=h.on((function(e){if(e instanceof da)if(e.stateType===sa.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=fs.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=fs.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=fs.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){fs.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 Zp[this._iid])}}],[{key:"of",value:function(e){return Zp[e]||(Zp[e]=new n({_iid:e})),Zp[e].ref++,Zp[e]}},{key:"clear",value:function(e){Zp[e]&&(Zp[e].close(),delete Zp[e])}}]),n}(),Xp=function(){function n(a,s){var i=this,o=s.filter,u=s.order,c=s.limit;r(this,n),this.channels=[],this._iid=a,this._key="gcc-".concat(re()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this.filter=null!=o?o:new vd,this.order=null!=u?u:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=c?c:100;var l=fs.of(this._iid),h=l.sdkState,d=l.cacheContext,f=l.dispatcher;d.localCacheEnabled&&(this._backgroundSync=Yp.of(a),this._backgroundSync.resume()),this._changelogSync=Jp.of(a),this._changelogSync.resume(),Ff.of(this._iid).subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){if(hu(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)}}),fs.of(this._iid).statLogCollector.put(new ss({type:Ae.FEATURE_LOCALCACHE,data:{use_local_cache:d.localCacheEnabled,collection_interface:{group_channel:!0}}})),f.on((function(e){e instanceof da&&(e.stateType===sa.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===sa.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=Jf(this.channels,h);d>=0&&this.channels.splice(d,1);var f=Xf(this.channels,h,this.order).place;if(d<0)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!==d&&this._hasMore&&f===this.channels.length?c.push(h):(this.channels.splice(f,0,h),u.push(h));break;default:this.channels.splice(f,0,h),u.push(h)}}}catch(e){l.e(e)}finally{l.f()}if(c.length>0){var p,v=y(c);try{for(v.s();!(p=v.n()).done;){var _=p.value,m=Jf(this.channels,_);-1!==m&&this.channels.splice(m,1)}}catch(e){v.e(e)}finally{v.f()}}hu(r)&&Ca((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 qf(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 hu(n)&&s.length>0&&Ca((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 qf(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=Ff.of(this._iid),r=this.channels.length>0?Zf(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:void 0);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=Ff.of(this._iid),e.next=3,n.getMyGroupChannels(this._token,ce(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=fs.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(),Ff.of(this._iid).unsubscribeGroupChannelEvent(this._key))}}]),n}(),$p=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=le.GET,s.path=pe,s.params=ue(ce({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)}(Oe),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)).channels=[];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 Kp(e,t)}))),s.ts="number"==typeof u?u:0,s}return s(n)}(Ue);e.MembershipFilter=void 0,(Qp=e.MembershipFilter||(e.MembershipFilter={})).ALL="all",Qp.JOINED="joined";var tv,nv=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=fs.of(this._iid),a=r.requestQueue,r.dispatcher,s=new $p(ce(Object.assign(Object.assign({},this),{token:this._token}))),e.next=9,a.send(s);case 9:return i=e.sent,o=i.as(ev),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}(Ii),rv=s((function e(){r(this,e),this.onUserMuted=He,this.onUserUnmuted=He,this.onUserBanned=He,this.onUserUnbanned=He,this.onChannelChanged=He,this.onChannelDeleted=He,this.onChannelFrozen=He,this.onChannelUnfrozen=He,this.onOperatorUpdated=He,this.onChannelMemberCountChanged=He,this.onMetaDataCreated=He,this.onMetaDataUpdated=He,this.onMetaDataDeleted=He,this.onMetaCounterCreated=He,this.onMetaCounterUpdated=He,this.onMetaCounterDeleted=He,this.onMessageReceived=He,this.onMessageUpdated=He,this.onMessageDeleted=He,this.onMentionReceived=He,this.onReactionUpdated=He,this.onThreadInfoUpdated=He})),av=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.apply(this,arguments)).onUserJoined=He,e.onUserLeft=He,e.onUserReceivedInvitation=He,e.onUserDeclinedInvitation=He,e.onChannelHidden=He,e.onUnreadMemberStatusUpdated=He,e.onUndeliveredMemberStatusUpdated=He,e.onTypingStatusUpdated=He,e.onPollUpdated=He,e.onPollVoted=He,e.onPollDeleted=He,e.onPinnedMessageUpdated=He,e}return s(n)}(rv),sv=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)}(av),iv=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=le.GET,a.path="".concat(we),a.params=ue(ce({token:s,limit:i,reverse:u,channel_url:c,order:o,message_type:l,status:h})),a}return s(n)}(Oe),ov=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).scheduledMessages=[];var i=a.next,o=a.scheduled_messages;return s.token=i,s.scheduledMessages=o.map((function(t){return Bs(e,t)})),s}return s(n)}(Ue),uv=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=fs.of(this._iid),r=n.requestQueue,a=new iv(ce(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(ov),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}(Ii),cv=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 Ff(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 Xp(this._iid,e)}},{key:"createMyGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Rf(this._iid,e)}},{key:"createPublicGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new nv(this._iid,e)}},{key:"createScheduledMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new uv(this._iid,e)}},{key:"addGroupChannelHandler",value:function(e,t){Za(L("string",e)&&t instanceof sv).throw(A.invalidParameters),this._manager.addHandler(e,t)}},{key:"removeGroupChannelHandler",value:function(e){Za(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 Za(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 Za(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({},bd),n),Za(L("string",e)&&Ed(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({},bd),n),Za(L("number",e)&&Ed(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({},wd),e),Za(Cd(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({},yd),e),Za(kd(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({},yd),e),Za(kd(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?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0,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({},yd),{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:Za(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 Za(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}(ps),lv=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!!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){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._channels.get(e));case 1:case"end":return t.stop()}}),n,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}(Ha),hv={channelUrl:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0},dv=function(e){return F("string",e.operatorUserIds,!0)&&(L("string",e.coverUrlOrImage,!0)||q(e.coverUrlOrImage,!0))&&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||void 0===e.channelUrl)&&L("boolean",e.isEphemeral,!0)},fv=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=le.GET,a.path="".concat(i?me:_e,"/").concat(encodeURIComponent(s)),a}return s(n)}(Oe),pv=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 Mv(e,a),s}return s(n)}(Ue),vv=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=le.POST,a.path=_e,a.params=ue(ce({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)}(Oe),_v=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)}(oa),mv=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 Xa(e,s.data),i.ts=null!==(u=s.data.edge_ts)&&void 0!==u?u:0),i}return s(n)}(tf),gv=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)}(oa),yv=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 Xa(e,s.data),i.ts=null!==(u=s.data.edge_ts)&&void 0!==u?u:0),i}return s(n)}(tf),kv={},bv=function(){function n(e,t){var a=this,s=t.sdkState,i=t.dispatcher,o=t.requestQueue;return r(this,n),kv[e]||(this._iid=e,this._sdkState=s,this._requestQueue=o,this._dispatcher=i,this._openChannelCache=new lv(e),this._openChannelHandlers=new Map,this._dispatcher.on((function(e){if(e instanceof qe)a._handleEvent(e);else if(e instanceof da&&e.stateType===sa.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()}}})),kv[e]=this),kv[e]}return s(n,[{key:"buildOpenChannelFromSerializedData",value:function(e){var t=Ya(e);return new Mv(this._iid,Mv.payloadify(t))}},{key:"getChannelFromCache",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.next=2,this._openChannelCache.get(e);case 2:if(t.t1=n=t.sent,t.t0=null!==t.t1,!t.t0){t.next=6;break}t.t0=void 0!==n;case 6:if(!t.t0){t.next=10;break}t.t2=n,t.next=11;break;case 10:t.t2=null;case 11:return t.abrupt("return",t.t2);case 12:case"end":return t.stop()}}),r,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,C,x,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,Ce,xe,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(Th):"FILE"===n.code?a=n.as(Ys):"ADMM"!==n.code&&"BRDM"!=n.code||(a=n.as(Nf)),!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,Ca((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&&a.onMessageReceived(u,i),o&&a.onMentionReceived&&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(Ih):"FEDI"===n.code?c=n.as(Mh):"AEDI"===n.code&&(c=n.as(Mf)),!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,Ca((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&&a.onMessageUpdated(f,h),d>0&&a.onMentionReceived&&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(Oh),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,Ca((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&&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(Af),E=k.channelUrl,w=k.channelType,C=k.event,w!==e.ChannelType.OPEN){r.next=37;break}return r.next=35,this.getChannel(E,!0);case 35:x=r.sent,Ca((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(x.url)&&a.onReactionUpdated&&a.onReactionUpdated(x,C)}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(Of),(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,Ca((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&&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(Sf),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,Ca((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).onChannelMemberCountChanged&&a.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(Uf),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 di({event:j,source:e.MessageEventSource.EVENT_POLL_UPDATED})),Ca(z===Ds?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).onPollDeleted&&a.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,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).onPollUpdated&&a.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(td),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 fi({event:W,source:e.MessageEventSource.EVENT_POLL_VOTED})),Ca((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).onPollVoted&&a.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(tf),!($=X.event).isOpenChannelEvent){r.next=165;break}r.t2=$.category,r.next=r.t2===pd.CHANNEL_ENTER?94:r.t2===pd.CHANNEL_EXIT?101:r.t2===pd.CHANNEL_OPERATOR_UPDATE?108:r.t2===pd.USER_CHANNEL_MUTE||r.t2===pd.USER_CHANNEL_UNMUTE?116:r.t2===pd.USER_CHANNEL_BAN||r.t2===pd.USER_CHANNEL_UNBAN?123:r.t2===pd.CHANNEL_FREEZE||r.t2===pd.CHANNEL_UNFREEZE?130:r.t2===pd.CHANNEL_DELETED?138:r.t2===pd.CHANNEL_PROP_CHANGED?145:r.t2===pd.CHANNEL_META_DATA_CHANGED?150:r.t2===pd.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(mv),ne=te.participantCount,re=te.user,ae=ee._updateParticipantCount(ne,$.ts),Ca((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&&e.onUserEntered(ee,re),ae&&e.onChannelParticipantCountChanged&&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(yv),oe=ie.participantCount,ue=ie.user,ce=se._updateParticipantCount(oe,$.ts),Ca((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&&e.onUserExited(se,ue),ce&&e.onChannelParticipantCountChanged&&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(Tf),de=he.operators,le.operators=de,this.upsertChannelsToCache([le]),Ca((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&&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===pd.USER_CHANNEL_MUTE,ve=n.as(pe?fh:vh),_e=ve.user,Ca((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&&e.onUserMuted(fe,_e):e.onUserUnmuted&&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===pd.USER_CHANNEL_BAN,ye=n.as(ge?mh:yh),ke=ye.user,Ca((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&&e.onUserBanned(me,ke):e.onUserUnbanned&&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(bh),we=Ee.freeze,be.isFrozen=we,this.upsertChannelsToCache([be]),Ca((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&&e.onChannelFrozen(be):e.onChannelUnfrozen&&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 Ce=r.sent,r.next=143,this.removeChannelsFromCache([Ce.url]);case 143:return Ca((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&&e.onChannelDeleted(Ce.url,Ce.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 xe=r.sent,Ca((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&&e.onChannelChanged(xe)}));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(Xl),Ie=Se.created,Ne=Se.updated,Me=Se.deleted,Ie&&Te._upsertCachedMetaData(Ie,$.ts),Ne&&Te._upsertCachedMetaData(Ne,$.ts),Me&&Te._removeFromCachedMetaData(Me,$.ts),Ca((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&&e.onMetaDataCreated(Te,Ie),Ne&&e.onMetaDataUpdated&&e.onMetaDataUpdated(Te,Ne),Me&&e.onMetaDataDeleted&&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(ch),Ue=Oe.created,Re=Oe.updated,Le=Oe.deleted,Ca((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&&e.onMetaCounterCreated(Ae,Ue),Re&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Ae,Re),Le&&e.onMetaCounterDeleted&&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 Za(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 Za(L("string",e)).throw(A.invalidParameters),a=new fv({channelUrl:e,isInternalCall:n}),t.next=4,this._requestQueue.send(a);case 4:return s=t.sent,i=s.as(pv),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({},hv),e),Za(dv(r)).throw(A.invalidParameters),a=new vv(r),t.next=5,this._requestQueue.send(a);case 5:return s=t.sent,i=s.as(pv),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 kv[e]}}]),n}(),Ev={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0},wv=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)},Cv=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=le.GET,a.path="".concat(_e,"/").concat(encodeURIComponent(s),"/participants"),a.params={token:i,limit:o},a}return s(n)}(Oe),xv=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).participants=[];var i=a.next,o=a.participants;return s.token=i,s.participants=o.map((function(t){return new Cl(e,t)})),s}return s(n)}(Ue),Tv=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=fs.of(this._iid),r=n.requestQueue,a=new Cv(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(xv),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}(Li),Sv=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=le.PUT,a.path="".concat(_e,"/").concat(encodeURIComponent(s)),a.params=ue(ce({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)}(Oe),Iv=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 Mv(e,a),s}return s(n)}(Ue),Nv=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=le.DELETE,a.path="".concat(_e,"/").concat(encodeURIComponent(s)),a}return s(n)}(Oe),Mv=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 Xa(t,e)})):[],s}return s(u,[{key:"serialize",value:function(){return Wa(this)}},{key:"isOperator",value:function(e){return e instanceof Xa?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 Tv(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=bv.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=fs.of(this._iid),r=n.requestQueue,a=new _v({channelUrl:this.url}),e.next=4,r.send(a);case 4:s=e.sent,i=s.as(mv),o=i.participantCount,u=i.ts,this._updateParticipantCount(o,u),bv.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=fs.of(this._iid),r=n.requestQueue,a=new gv({channelUrl:this.url}),e.next=4,r.send(a);case 4:s=e.sent,i=s.as(yv),o=i.participantCount,u=i.ts,this._updateParticipantCount(o,u),bv.of(this._iid).setExitedToCache(this),wi.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({},Ev),e),Za(wv(r)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.requestQueue,i=new Sv(Object.assign({channelUrl:this.url},r)),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(Iv),c=u.channel,this._update(c),l=bv.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({},Ev),{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=fs.of(this._iid),r=n.requestQueue,a=new Nv({channelUrl:this.url}),e.next=4,r.send(a);case 4:return s=bv.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 Za(!e.isPinnedMessage).throw(A.notSupportedError),p(o(u.prototype),"sendUserMessage",this).call(this,e)}},{key:"sendFileMessage",value:function(e){return Za(!e.isPinnedMessage).throw(A.notSupportedError),p(o(u.prototype),"sendFileMessage",this).call(this,e)}}],[{key:"payloadify",value:function(e){return ue(ce(Object.assign(Object.assign({},nd.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return Xa.payloadify(e)}))})))}}]),u}(nd),Av=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.apply(this,arguments)).onUserEntered=He,e.onUserExited=He,e.onChannelParticipantCountChanged=He,e.onPollUpdated=He,e.onPollVoted=He,e.onPollDeleted=He,e}return s(n)}(rv),Ov=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)}(Av),Uv=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=le.GET,a.path=_e,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)}(Oe),Rv=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).channels=[];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 Mv(e,t)}))),s.ts="number"==typeof u?u:null,s}return s(n)}(Ue),Lv=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=fs.of(this._iid),r=n.requestQueue,a=new Uv(ce(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Rv),o=i.channels,u=i.token,this._token=u,this._hasNext=!!u,c=bv.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}(Ii),Dv=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 bv(e,{sdkState:n,dispatcher:r,requestQueue:i})}},{key:"createOpenChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Lv(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({},hv)).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}(ps);tv=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 jv(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 zv(e){return"string"!=typeof e&&(e=String(e)),e}function Vv(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return Gv.iterable&&(t[Symbol.iterator]=function(){return t}),t}function Bv(e){this.map={},e instanceof Bv?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 Qv(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function Kv(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function Wv(e){var t=new FileReader,n=Kv(t);return t.readAsArrayBuffer(e),n}function Yv(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function Zv(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:Gv.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:Gv.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:Gv.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():Gv.arrayBuffer&&Gv.blob&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=Yv(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):Gv.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||Hv(e))?this._bodyArrayBuffer=Yv(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):Gv.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},Gv.blob&&(this.blob=function(){var e=Qv(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=Qv(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(Wv)}),this.text=function(){var e,t,n,r=Qv(this);if(r)return r;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=Kv(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 $v(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 e_(e,t){if(!(this instanceof e_))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 Bv(t.headers),this.url=t.url||"",this._initBody(e)}Xv.prototype.clone=function(){return new Xv(this,{body:this._bodyInit})},Zv.call(Xv.prototype),Zv.call(e_.prototype),e_.prototype.clone=function(){return new e_(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new Bv(this.headers),url:this.url})},e_.error=function(){var e=new e_(null,{status:0,statusText:""});return e.type="error",e};var t_=[301,302,303,307,308];e_.redirect=function(e,t){if(-1===t_.indexOf(t))throw new RangeError("Invalid status code");return new e_(null,{status:t,headers:{location:e}})};var n_=Fv.DOMException;try{new n_}catch(sn){(n_=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack}).prototype=Object.create(Error.prototype),n_.prototype.constructor=n_}function r_(e,t){return new Promise((function(r,a){var s=new Xv(e,t);if(s.signal&&s.signal.aborted)return a(new n_("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 Bv,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 e_(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 n_("Aborted","AbortError"))}),0)},i.open(s.method,function(e){try{return""===e&&Fv.location.href?Fv.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&&(Gv.blob?i.responseType="blob":Gv.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 Bv?s.headers.forEach((function(e,t){i.setRequestHeader(t,e)})):Object.getOwnPropertyNames(t.headers).forEach((function(e){i.setRequestHeader(e,zv(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)}))}r_.polyfill=!0,Fv.fetch||(Fv.fetch=r_,Fv.Headers=Bv,Fv.Request=Xv,Fv.Response=e_);var a_=Object.freeze({__proto__:null});return e.AdminMessage=Rs,e.AppleCriticalAlertOptions=xs,e.ApplicationUserListQuery=gc,e.BannedUserListQuery=Gl,e.BaseChannel=nd,e.BaseMessage=Ns,e.BlockedUserListQuery=bc,e.CachedChannelInfo=ee,e.ConnectionHandler=_o,e.Emoji=sc,e.EmojiCategory=ic,e.EmojiContainer=oc,e.FileMessage=Qs,e.FriendListQuery=Cc,e.GroupChannel=Kp,e.GroupChannelCollection=Xp,e.GroupChannelEventContext=qf,e.GroupChannelFilter=vd,e.GroupChannelHandler=sv,e.GroupChannelListQuery=Rf,e.GroupChannelModule=cv,e.LocalCacheConfig=te,e.Member=dd,e.MemberListQuery=_p,e.MemoryStore=ll,e.MessageCollection=up,e.MessageCollectionInitHandler=op,e.MessageEventContext=Hf,e.MessageFilter=wo,e.MessageMetaArray=Es,e.MessageModule=qi,e.MessageRequestHandler=Ci,e.MessageSearchQuery=Ri,e.MultipleFilesMessage=zs,e.MultipleFilesMessageRequestHandler=Gi,e.MutedUserListQuery=Dl,e.OGImage=ws,e.OGMetaData=Cs,e.OpenChannel=Mv,e.OpenChannelHandler=Ov,e.OpenChannelListQuery=Lv,e.OpenChannelModule=Dv,e.OperatorListQuery=Ul,e.Participant=Cl,e.ParticipantListQuery=Tv,e.PinnedMessage=jp,e.PinnedMessageListQuery=Bp,e.Plugin=Ls,e.PreviousMessageListQuery=Di,e.PublicGroupChannelListQuery=nv,e.Reaction=bs,e.ReactionEvent=ks,e.ReadStatus=fd,e.RestrictedUser=wl,e.RestrictionInfo=El,e.ScheduledMessageListQuery=uv,e.SendbirdChat=rd,e.SendbirdChatOptions=H,e.SendbirdError=A,e.Sender=Ts,e.SessionHandler=vo,e.ThreadInfo=ms,e.ThreadInfoUpdateEvent=xi,e.Thumbnail=As,e.UIKitConfigInfo=Fa,e.UploadedFileInfo=js,e.User=Xa,e.UserEventHandler=mo,e.UserMessage=Hs,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 S(r||[]);return a(i,"_invoke",{value:b(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(T([])));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 E(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 b(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 C(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 x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(C,this),this.reset(!0)}function T(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),x(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;x(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:T(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 E(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())}))}"function"==typeof SuppressedError&&SuppressedError;var b,w="4.9.4-rc.1",C=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_COMMAND=700700]="INVALID_COMMAND",e[e.UNKNOWN_ERROR=77e4]="UNKNOWN_ERROR",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"}(b||(b={}));var x,S,T,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===b.INVALID_TOKEN}},{key:"isSessionTokenExpiredError",get:function(){return this.code===b.SESSION_TOKEN_EXPIRED}},{key:"isSessionKeyExpiredError",get:function(){return this.code===b.SESSION_KEY_EXPIRED}},{key:"isSessionRevokedError",get:function(){return this.code===b.SESSION_REVOKED}},{key:"throwOutside",value:function(){throw this.shouldThrowOutside=!0,this}}],[{key:"debugModeRequired",get:function(){return new n({code:b.DEBUG_MODE_REQUIRED,message:"Cannot run this operation in production mode."})}},{key:"lostInstance",get:function(){return new n({code:b.LOST_INSTANCE,message:"Instance ID is missing. It should belong to an instance."})}},{key:"invalidCommand",get:function(){return new n({code:b.INVALID_COMMAND,message:"Cannot send invalid command."})}},{key:"unknown",get:function(){return new n({code:b.UNKNOWN_ERROR,message:"Unknown error occurred."})}},{key:"connectionRenew",get:function(){return new n({code:b.CONNECTION_RENEW,message:"Connection restarts."})}},{key:"invalidConnectionStateTransition",get:function(){return new n({code:b.INVALID_CONNECTION_STATE_TRANSITION,message:"Invalid connection state transition."})}},{key:"connectionRequired",get:function(){return new n({code:b.CONNECTION_REQUIRED,message:"Connection is required."})}},{key:"connectionCanceled",get:function(){return new n({code:b.CONNECTION_CANCELED,message:"Connection is canceled."})}},{key:"invalidParameters",get:function(){return new n({code:b.INVALID_PARAMETER,message:"Invalid parameters."})}},{key:"notSupportedError",get:function(){return new n({code:b.NOT_SUPPORTED_ERROR,message:"Given parameters are not supported."})}},{key:"networkError",get:function(){return new n({code:b.NETWORK_ERROR,message:"There was a network error."})}},{key:"markAsReadAllRateLimitExceeded",get:function(){return new n({code:b.MARK_AS_READ_RATE_LIMIT_EXCEEDED,message:"markAsRead rate limit exceeded."})}},{key:"queryInProgress",get:function(){return new n({code:b.QUERY_IN_PROGRESS,message:"Query in progress."})}},{key:"noAckTimeout",get:function(){return new n({code:b.ACK_TIMEOUT,message:"Command received no ack."})}},{key:"loginTimeout",get:function(){return new n({code:b.LOGIN_TIMEOUT,message:"Connection timeout."})}},{key:"connectionClosed",get:function(){return new n({code:b.WEBSOCKET_CONNECTION_CLOSED,message:"Connection is closed. Please reconnect."})}},{key:"requestFailed",get:function(){return new n({code:b.REQUEST_FAILED,message:"Request failed."})}},{key:"fileUploadCanceled",get:function(){return new n({code:b.FILE_UPLOAD_CANCEL_FAILED,message:"File upload has been canceled."})}},{key:"requestCanceled",get:function(){return new n({code:b.REQUEST_CANCELED,message:"Request has been canceled."})}},{key:"sessionTokenRefreshFailed",get:function(){return new n({code:b.SESSION_TOKEN_REFRESH_FAILED,message:"Failed to refresh the session key."})}},{key:"sessionTokenRequestFailed",get:function(){return new n({code:b.SESSION_TOKEN_REQUEST_FAILED,message:"Failed to get the session token."})}},{key:"databaseError",get:function(){return new n({code:b.DATABASE_ERROR,message:"Database error."})}},{key:"fileSizeLimitExceededError",get:function(){return new n({code:b.FILE_SIZE_LIMIT_EXCEEDED,message:"File size exceeds the file size limit."})}}]),n}(h(Error)),O=[b.CONNECTION_REQUIRED,b.NETWORK_ERROR,b.ACK_TIMEOUT,b.WEBSOCKET_CONNECTION_CLOSED,b.WEBSOCKET_CONNECTION_FAILED,b.FILE_UPLOAD_CANCEL_FAILED,b.REQUEST_CANCELED,b.INTERNAL_SERVER_ERROR,b.RATE_LIMIT_EXCEEDED,b.UNKNOWN_SERVER_ERROR],U=[b.WEBSOCKET_CONNECTION_CLOSED,b.WEBSOCKET_CONNECTION_FAILED,b.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="object"===n(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 E(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 E(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;r(this,e),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||t.channel.lastMessage?e.channel.lastMessage.createdAt-t.channel.lastMessage.createdAt:0:e.channel.messageCollectionLastAccessedAt>t.channel.messageCollectionLastAccessedAt?1:-1},this._maxSize=Math.max(a,64),o?(this._clearOrder=i,this._customClearOrderComparator=o):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)}return s(e,[{key:"hasSession",get:function(){return!!this.sessionKey}},{key:"clear",value:function(){this.authToken=void 0,this.sessionKey=void 0}}]),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){var r;return e in this._container||(this._container[e]=new Map),null===(r=this._container[e])||void 0===r||r.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(){var e;for(var t in this._container)null===(e=this._container[t])||void 0===e||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},ce=function e(t){if(null!=t){if("object"===n(t)){if(Array.isArray(t)){var r=_(t);for(var a in r)r[a]=e(r[a]);return r}for(var s in t)null===t[s]&&delete t[s];return t}return 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 le,he="v3",de="/".concat(he,"/users"),fe="/".concat(he,"/storage/file"),pe="/".concat(he,"/group_channels"),ve="/".concat(he,"/sdk/group_channels"),_e="/".concat(he,"/open_channels"),me="/".concat(he,"/sdk/open_channels"),ge="/".concat(he,"/search"),ye="/".concat(he,"/report"),ke="/".concat(he,"/emojis"),Ee="/".concat(he,"/emoji_categories"),be="/".concat(he,"/polls"),we="/".concat(he,"/scheduled_messages"),Ce="/".concat(he,"/sdk/ui_kit/configuration"),xe="/".concat(he,"/sdk/statistics"),Se=function(t){switch(t){case e.ChannelType.GROUP:return pe;case e.ChannelType.OPEN:return _e;default:return null}},Te=function(t){switch(t){case e.ChannelType.GROUP:return"".concat(ye,"/group_channels");case e.ChannelType.OPEN:return"".concat(ye,"/open_channels");default:return null}},Ie=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},Ne=function(e,t,n){var r,a,s,i,o=Ie(null!==(r=e.mentionType)&&void 0!==r?r:null,null!==(a=e.mentionedUserIds)&&void 0!==a?a:[],n),u=Ie(null!==(s=t.mentionType)&&void 0!==s?s:null,null!==(i=t.mentionedUserIds)&&void 0!==i?i:[],n);return!o&&u?1:o&&!u?-1:0},Me=function e(t,r,a){var s,i=r||new FormData;for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o)){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"}(le||(le={}));var Ae,Oe=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])}))?Me(e):JSON.stringify(e)}}]),a}(oe),Ue=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),Re=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),Le=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?b.SESSION_KEY_EXPIRED:i;switch(r(this,n),(a=t.call(this)).expiresIn=null!=s?s:0,o){case b.SESSION_KEY_EXPIRED:case b.SESSION_TOKEN_EXPIRED:case b.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),De=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"}(Ae||(Ae={}));var Pe=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}(),Fe=function(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"==navigator.product},Ge=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 Re&&a.cancel(e.requestId)})),this._logger=u,this._shouldImportFetchCompat=l}return s(e,[{key:"_userAgentWithExtension",get:function(){var e=this._sdkState.extensions,t=Fe()?"reactnative":"JS",n="//";if(e){var r=e.sb_syncmanager?"s".concat(e.sb_syncmanager):"",a=e.sb_uikit?"u".concat(e.sb_uikit):"",s=e["device-os-platform"]?"o".concat(e["device-os-platform"]):"";n="".concat(r,"/").concat(a,"/").concat(s)}return"".concat(t,"/c").concat(C.SDK_VERSION,"/").concat(n)}},{key:"_createHeader",value:function(e,t){var n=this._sdkState,r=n.appId,a=n.appVersion,s=Object.assign(Object.assign({},e.headers),{SendBird:"JS,".concat(C.OS_VERSION,",").concat(C.SDK_VERSION,",").concat(r).concat(a?",".concat(a):""),"SB-User-Agent":encodeURIComponent(this._userAgentWithExtension),"Request-Sent-Timestamp":Date.now().toString()});return t||(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 De(new Pe({type:Ae.API_RESULT,data:{endpoint:e.path,method:e.method,success:!n,latency:Date.now()-t,error_code:null==n?void 0:n.code,error_description:null==n?void 0:n.message}})))}},{key:"send",value:function(e){return E(this,void 0,void 0,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=![le.GET,le.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:void 0),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=null),"undefined"!=typeof AbortController){t.next=15;break}return t.next=15,Promise.resolve().then((function(){return Pv}));case 15:if("function"==typeof fetch){t.next=18;break}return t.next=18,Promise.resolve().then((function(){return u_}));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),t.abrupt("return",new Ue(this._iid,p));case 30:if(!p){t.next=37;break}throw((v=new A(p)).isSessionKeyExpiredError||v.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new Le({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}(),qe=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u=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=null!==(o=s.req_id)&&void 0!==o?o:u,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={};try{a=JSON.parse(t.substring(4))}catch(e){r="NOOP"}finally{return new n(e,r,a)}}}]),n}(oe),He=function(){};function je(e){let t=e.length;for(;--t>=0;)e[t]=0}const ze=256,Ve=286,Be=30,Qe=15,Ke=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]),We=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]),Ye=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]),Je=new Array(576);je(Je);const Xe=new Array(60);je(Xe);const $e=new Array(512);je($e);const et=new Array(256);je(et);const tt=new Array(29);je(tt);const nt=new Array(Be);function rt(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 at,st,it;function ot(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}je(nt);const ut=e=>e<256?$e[e]:$e[256+(e>>>7)],ct=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},lt=(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<{lt(e,n[2*t],n[2*t+1])},dt=(e,t)=>{let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1},ft=(e,t,n)=>{const r=new Array(16);let a,s,i=0;for(a=1;a<=Qe;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]=dt(r[t]++,t))}},pt=e=>{let t;for(t=0;t{e.bi_valid>8?ct(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},_t=(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?ht(e,a,t):(s=et[a],ht(e,s+ze+1,t),i=Ke[s],0!==i&&(a-=tt[s],lt(e,a,i)),r--,s=ut(r),ht(e,s,n),i=We[s],0!==i&&(r-=nt[s],lt(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--)mt(e,n,i);u=s;do{i=e.heap[1],e.heap[1]=e.heap[e.heap_len--],mt(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++,mt(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<=Qe;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),ft(n,c,e.bl_count)},kt=(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{lt(e,0+(r?1:0),3),vt(e),ct(e,n),ct(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var Ct=(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(kt(e,e.dyn_ltree,e.l_desc.max_code),kt(e,e.dyn_dtree,e.d_desc.max_code),yt(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),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?wt(e,t,n,r):4===e.strategy||s===a?(lt(e,2+(r?1:0),3),gt(e,Je,Xe)):(lt(e,4+(r?1:0),3),((e,t,n,r)=>{let a;for(lt(e,t-257,5),lt(e,n-1,5),lt(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(tt[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*(et[n]+ze+1)]++,e.dyn_dtree[2*ut(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{lt(e,2,3),ht(e,256,Je),(e=>{16===e.bi_valid?(ct(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 St=(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 It=(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},Nt={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"},Mt={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:At,_tr_stored_block:Ot,_tr_flush_block:Ut,_tr_tally:Rt,_tr_align:Lt}=xt,{Z_NO_FLUSH:Dt,Z_PARTIAL_FLUSH:Pt,Z_FULL_FLUSH:Ft,Z_FINISH:Gt,Z_BLOCK:qt,Z_OK:Ht,Z_STREAM_END:jt,Z_STREAM_ERROR:zt,Z_DATA_ERROR:Vt,Z_BUF_ERROR:Bt,Z_DEFAULT_COMPRESSION:Qt,Z_FILTERED:Kt,Z_HUFFMAN_ONLY:Wt,Z_RLE:Yt,Z_FIXED:Zt,Z_DEFAULT_STRATEGY:Jt,Z_UNKNOWN:Xt,Z_DEFLATED:$t}=Mt,en=258,tn=262,nn=42,rn=113,an=666,sn=(e,t)=>(e.msg=Nt[t],t),on=e=>2*e-(e>4?9:0),un=e=>{let t=e.length;for(;--t>=0;)e[t]=0},cn=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 ln=(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))},dn=(e,t)=>{Ut(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,hn(e.strm)},fn=(e,t)=>{e.pending_buf[e.pending++]=t},pn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},vn=(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=St(e.adler,t,a,n):2===e.state.wrap&&(e.adler=It(e.adler,t,a,n)),e.next_in+=a,e.total_in+=a,a)},_n=(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-tn?e.strstart-(e.w_size-tn):0,c=e.window,l=e.w_mask,h=e.prev,d=e.strstart+en;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},mn=e=>{const t=e.w_size;let n,r,a;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-tn)&&(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),cn(e),r+=t),0===e.strm.avail_in)break;if(n=vn(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=ln(e,e.ins_h,e.window[a+1]);e.insert&&(e.ins_h=ln(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,hn(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&&(vn(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&&(vn(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===Gt)&&t!==Dt&&0===e.strm.avail_in&&r<=a)&&(n=r>a?a:r,i=t===Gt&&0===e.strm.avail_in&&n===r?1:0,Ot(e,e.block_start,n,i),e.block_start+=n,hn(e.strm)),i?3:1)},yn=(e,t)=>{let n,r;for(;;){if(e.lookahead=3&&(e.ins_h=ln(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-tn&&(e.match_length=_n(e,n)),e.match_length>=3)if(r=Rt(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=ln(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=ln(e,e.ins_h,e.window[e.strstart+1]);else r=Rt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(dn(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Gt?(dn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(dn(e,!1),0===e.strm.avail_out)?1:2},kn=(e,t)=>{let n,r,a;for(;;){if(e.lookahead=3&&(e.ins_h=ln(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=Rt(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=ln(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&&(dn(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=Rt(e,0,e.window[e.strstart-1]),r&&dn(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=Rt(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Gt?(dn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(dn(e,!1),0===e.strm.avail_out)?1:2};function En(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 En(0,0,0,0,gn),new En(4,4,8,4,yn),new En(4,5,16,8,yn),new En(4,6,32,32,yn),new En(4,4,16,16,kn),new En(8,16,32,32,kn),new En(8,16,128,128,kn),new En(8,32,128,256,kn),new En(32,128,258,1024,kn),new En(32,258,258,4096,kn)];function wn(){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=$t,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),un(this.dyn_ltree),un(this.dyn_dtree),un(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),un(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),un(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 Cn=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==nn&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==rn&&t.status!==an?1:0},xn=e=>{if(Cn(e))return sn(e,zt);e.total_in=e.total_out=0,e.data_type=Xt;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?nn:rn,e.adler=2===t.wrap?0:1,t.last_flush=-2,At(t),Ht},Sn=e=>{const t=xn(e);var n;return t===Ht&&((n=e.state).window_size=2*n.w_size,un(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 zt;let i=1;if(t===Qt&&(t=6),r<0?(i=0,r=-r):r>15&&(i=2,r-=16),a<1||a>9||n!==$t||r<8||r>15||t<0||t>9||s<0||s>Zt||8===r&&1!==i)return sn(e,zt);8===r&&(r=9);const o=new wn;return e.state=o,o.strm=e,o.status=nn,o.wrap=i,o.gzhead=null,o.w_bits=r,o.w_size=1<Tn(e,t,$t,15,8,Jt),deflateInit2:Tn,deflateReset:Sn,deflateResetKeep:xn,deflateSetHeader:(e,t)=>Cn(e)||2!==e.state.wrap?zt:(e.state.gzhead=t,Ht),deflate:(e,t)=>{if(Cn(e)||t>qt||t<0)return e?sn(e,zt):zt;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===an&&t!==Gt)return sn(e,0===e.avail_out?Bt:zt);const r=n.last_flush;if(n.last_flush=t,0!==n.pending){if(hn(e),0===e.avail_out)return n.last_flush=-1,Ht}else if(0===e.avail_in&&on(t)<=on(r)&&t!==Gt)return sn(e,Bt);if(n.status===an&&0!==e.avail_in)return sn(e,Bt);if(n.status===nn&&0===n.wrap&&(n.status=rn),n.status===nn){let t=$t+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=Wt||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,pn(n,t),0!==n.strstart&&(pn(n,e.adler>>>16),pn(n,65535&e.adler)),e.adler=1,n.status=rn,hn(e),0!==n.pending)return n.last_flush=-1,Ht}if(57===n.status)if(e.adler=0,fn(n,31),fn(n,139),fn(n,8),n.gzhead)fn(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)),fn(n,255&n.gzhead.time),fn(n,n.gzhead.time>>8&255),fn(n,n.gzhead.time>>16&255),fn(n,n.gzhead.time>>24&255),fn(n,9===n.level?2:n.strategy>=Wt||n.level<2?4:0),fn(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(fn(n,255&n.gzhead.extra.length),fn(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=It(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(fn(n,0),fn(n,0),fn(n,0),fn(n,0),fn(n,0),fn(n,9===n.level?2:n.strategy>=Wt||n.level<2?4:0),fn(n,3),n.status=rn,hn(e),0!==n.pending)return n.last_flush=-1,Ht;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=It(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=a,hn(e),0!==n.pending)return n.last_flush=-1,Ht;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=It(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=It(e.adler,n.pending_buf,n.pending-r,r)),hn(e),0!==n.pending)return n.last_flush=-1,Ht;r=0}t=n.gzindexr&&(e.adler=It(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=It(e.adler,n.pending_buf,n.pending-r,r)),hn(e),0!==n.pending)return n.last_flush=-1,Ht;r=0}t=n.gzindexr&&(e.adler=It(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&&(hn(e),0!==n.pending))return n.last_flush=-1,Ht;fn(n,255&e.adler),fn(n,e.adler>>8&255),e.adler=0}if(n.status=rn,hn(e),0!==n.pending)return n.last_flush=-1,Ht}if(0!==e.avail_in||0!==n.lookahead||t!==Dt&&n.status!==an){let r=0===n.level?gn(n,t):n.strategy===Wt?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(mn(e),0===e.lookahead)){if(t===Dt)return 1;break}if(e.match_length=0,n=Rt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(dn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Gt?(dn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(dn(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===Yt?((e,t)=>{let n,r,a,s;const i=e.window;for(;;){if(e.lookahead<=en){if(mn(e),e.lookahead<=en&&t===Dt)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+en;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=Rt(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=Rt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(dn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Gt?(dn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(dn(e,!1),0===e.strm.avail_out)?1:2})(n,t):bn[n.level].func(n,t);if(3!==r&&4!==r||(n.status=an),1===r||3===r)return 0===e.avail_out&&(n.last_flush=-1),Ht;if(2===r&&(t===Pt?Lt(n):t!==qt&&(Ot(n,0,0,!1),t===Ft&&(un(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),hn(e),0===e.avail_out))return n.last_flush=-1,Ht}return t!==Gt?Ht:n.wrap<=0?jt:(2===n.wrap?(fn(n,255&e.adler),fn(n,e.adler>>8&255),fn(n,e.adler>>16&255),fn(n,e.adler>>24&255),fn(n,255&e.total_in),fn(n,e.total_in>>8&255),fn(n,e.total_in>>16&255),fn(n,e.total_in>>24&255)):(pn(n,e.adler>>>16),pn(n,65535&e.adler)),hn(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?Ht:jt)},deflateEnd:e=>{if(Cn(e))return zt;const t=e.state.status;return e.state=null,t===rn?sn(e,Vt):Ht},deflateSetDictionary:(e,t)=>{let n=t.length;if(Cn(e))return zt;const r=e.state,a=r.wrap;if(2===a||1===a&&r.status!==nn||r.lookahead)return zt;if(1===a&&(e.adler=St(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){0===a&&(un(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,mn(r);r.lookahead>=3;){let e=r.strstart,t=r.lookahead-2;do{r.ins_h=ln(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,mn(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,Ht},deflateInfo:"pako deflate (from Nodeca project)"};const Nn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Mn={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)Nn(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;On[254]=On[254]=1;var Un={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&&An)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+On[e[n]]>t?n:t}};var Rn=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 Ln=Object.prototype.toString,{Z_NO_FLUSH:Dn,Z_SYNC_FLUSH:Pn,Z_FULL_FLUSH:Fn,Z_FINISH:Gn,Z_OK:qn,Z_STREAM_END:Hn,Z_DEFAULT_COMPRESSION:jn,Z_DEFAULT_STRATEGY:zn,Z_DEFLATED:Vn}=Mt;function Bn(e){this.options=Mn.assign({level:jn,method:Vn,chunkSize:16384,windowBits:15,memLevel:8,strategy:zn},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 Rn,this.strm.avail_out=0;let n=In.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==qn)throw new Error(Nt[n]);if(t.header&&In.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?Un.string2buf(t.dictionary):"[object ArrayBuffer]"===Ln.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=In.deflateSetDictionary(this.strm,e),n!==qn)throw new Error(Nt[n]);this._dict_set=!0}}function Qn(e,t){const n=new Bn(t);if(n.push(e,!0),n.err)throw n.msg||Nt[n.err];return n.result}Bn.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?Gn:Dn,"string"==typeof e?n.input=Un.string2buf(e):"[object ArrayBuffer]"===Ln.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===Pn||s===Fn)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(a=In.deflate(n,s),a===Hn)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),a=In.deflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===qn;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},Bn.prototype.onData=function(e){this.chunks.push(e)},Bn.prototype.onEnd=function(e){e===qn&&(this.result=Mn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Kn={Deflate:Bn,deflate:Qn,deflateRaw:function(e,t){return(t=t||{}).raw=!0,Qn(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,Qn(e,t)},constants:Mt};const Wn=16209;var Yn=function(e,t){let n,r,a,s,i,o,u,c,l,h,d,f,p,v,_,m,g,y,k,E,b,w,C,x;const S=e.state;n=e.next_in,C=e.input,r=n+(e.avail_in-5),a=e.next_out,x=e.output,s=a-(t-e.avail_out),i=a+(e.avail_out-257),o=S.dmax,u=S.wsize,c=S.whave,l=S.wnext,h=S.window,d=S.hold,f=S.bits,p=S.lencode,v=S.distcode,_=(1<>>24,d>>>=y,f-=y,y=g>>>16&255,0===y)x[a++]=65535&g;else{if(!(16&y)){if(0==(64&y)){g=p[(65535&g)+(d&(1<>>=y,f-=y),f<15&&(d+=C[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",S.mode=Wn;break e}if(d>>>=y,f-=y,y=a-s,E>y){if(y=E-y,y>c&&S.sane){e.msg="invalid distance too far back",S.mode=Wn;break e}if(b=0,w=h,0===l){if(b+=u-y,y2;)x[a++]=w[b++],x[a++]=w[b++],x[a++]=w[b++],k-=3;k&&(x[a++]=w[b++],k>1&&(x[a++]=w[b++]))}else{b=a-E;do{x[a++]=x[b++],x[a++]=x[b++],x[a++]=x[b++],k-=3}while(k>2);k&&(x[a++]=x[b++],k>1&&(x[a++]=x[b++]))}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,E=0,b=0,w=0,C=0,x=null;const S=new Uint16Array(16),T=new Uint16Array(16);let I,N,M,A=null;for(v=0;v<=Zn;v++)S[v]=0;for(_=0;_=1&&0===S[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(T[1]=0,v=1;v852||2===e&&w>592)return 1;for(;;){I=v-E,i[_]+1=p?(N=A[i[_]-p],M=x[i[_]-p]):(N=96,M=0),c=1<>E)+l]=I<<24|N<<16|M|0}while(0!==l);for(c=1<>=1;if(0!==c?(C&=c-1,C+=c):C=0,_++,0==--S[v]){if(v===g)break;v=t[n+i[_]]}if(v>y&&(C&d)!==h){for(0===E&&(E=y),f+=m,k=v-E,b=1<852||2===e&&w>592)return 1;h=C&d,a[h]=y<<24|k<<16|f-s|0}}return 0!==C&&(a[f+C]=v-E<<24|64<<16|0),o.bits=y,0};const{Z_FINISH:nr,Z_BLOCK:rr,Z_TREES:ar,Z_OK:sr,Z_STREAM_END:ir,Z_NEED_DICT:or,Z_STREAM_ERROR:ur,Z_DATA_ERROR:cr,Z_MEM_ERROR:lr,Z_BUF_ERROR:hr,Z_DEFLATED:dr}=Mt,fr=16180,pr=16190,vr=16191,_r=16192,mr=16194,gr=16199,yr=16200,kr=16206,Er=16209,br=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function wr(){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 Cr=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},xr=e=>{if(Cr(e))return ur;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=fr,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,sr},Sr=e=>{if(Cr(e))return ur;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,xr(e)},Tr=(e,t)=>{let n;if(Cr(e))return ur;const r=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?ur:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,Sr(e))},Ir=(e,t)=>{if(!e)return ur;const n=new wr;e.state=n,n.strm=e,n.window=null,n.mode=fr;const r=Tr(e,t);return r!==sr&&(e.state=null),r};let Nr,Mr,Ar=!0;const Or=e=>{if(Ar){Nr=new Int32Array(512),Mr=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(tr(1,e.lens,0,288,Nr,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;tr(2,e.lens,0,32,Mr,0,e.work,{bits:5}),Ar=!1}e.lencode=Nr,e.lenbits=9,e.distcode=Mr,e.distbits=5},Ur=(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.whaveIr(e,15),inflateInit2:Ir,inflate:(e,t)=>{let n,r,a,s,i,o,u,c,l,h,d,f,p,v,_,m,g,y,k,E,b,w,C=0;const x=new Uint8Array(4);let S,T;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Cr(e)||!e.output||!e.input&&0!==e.avail_in)return ur;n=e.state,n.mode===vr&&(n.mode=_r),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=sr;e:for(;;)switch(n.mode){case fr:if(0===n.wrap){n.mode=_r;break}for(;l<16;){if(0===o)break e;o--,c+=r[s++]<>>8&255,n.check=It(n.check,x,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=Er;break}if((15&c)!==dr){e.msg="unknown compression method",n.mode=Er;break}if(c>>>=4,l-=4,b=8+(15&c),0===n.wbits&&(n.wbits=b),b>15||b>n.wbits){e.msg="invalid window size",n.mode=Er;break}n.dmax=1<>8&1),512&n.flags&&4&n.wrap&&(x[0]=255&c,x[1]=c>>>8&255,n.check=It(n.check,x,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,x[2]=c>>>16&255,x[3]=c>>>24&255,n.check=It(n.check,x,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&&(x[0]=255&c,x[1]=c>>>8&255,n.check=It(n.check,x,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=It(n.check,x,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&&(b=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),b)),512&n.flags&&4&n.wrap&&(n.check=It(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{b=r[s+f++],n.head&&b&&n.length<65536&&(n.head.name+=String.fromCharCode(b))}while(b&&f>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=vr;break;case 16189:for(;l<32;){if(0===o)break e;o--,c+=r[s++]<>>=7&l,l-=7&l,n.mode=kr;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(Or(n),n.mode=gr,t===ar){c>>>=2,l-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=Er}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=Er;break}if(n.length=65535&c,c=0,l=0,n.mode=mr,t===ar)break e;case mr: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=vr;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=Er;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,S={bits:n.lenbits},w=tr(0,n.lens,0,19,n.lencode,0,n.work,S),n.lenbits=S.bits,w){e.msg="invalid code lengths set",n.mode=Er;break}n.have=0,n.mode=16198;case 16198:for(;n.have>>24,m=C>>>16&255,g=65535&C,!(_<=l);){if(0===o)break e;o--,c+=r[s++]<>>=_,l-=_,n.lens[n.have++]=g;else{if(16===g){for(T=_+2;l>>=_,l-=_,0===n.have){e.msg="invalid bit length repeat",n.mode=Er;break}b=n.lens[n.have-1],f=3+(3&c),c>>>=2,l-=2}else if(17===g){for(T=_+3;l>>=_,l-=_,b=0,f=3+(7&c),c>>>=3,l-=3}else{for(T=_+7;l>>=_,l-=_,b=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=Er;break}for(;f--;)n.lens[n.have++]=b}}if(n.mode===Er)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=Er;break}if(n.lenbits=9,S={bits:n.lenbits},w=tr(1,n.lens,0,n.nlen,n.lencode,0,n.work,S),n.lenbits=S.bits,w){e.msg="invalid literal/lengths set",n.mode=Er;break}if(n.distbits=6,n.distcode=n.distdyn,S={bits:n.distbits},w=tr(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,S),n.distbits=S.bits,w){e.msg="invalid distances set",n.mode=Er;break}if(n.mode=gr,t===ar)break e;case gr:n.mode=yr;case yr: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,Yn(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===vr&&(n.back=-1);break}for(n.back=0;C=n.lencode[c&(1<>>24,m=C>>>16&255,g=65535&C,!(_<=l);){if(0===o)break e;o--,c+=r[s++]<>y)],_=C>>>24,m=C>>>16&255,g=65535&C,!(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=vr;break}if(64&m){e.msg="invalid literal/length code",n.mode=Er;break}n.extra=15&m,n.mode=16201;case 16201:if(n.extra){for(T=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;C=n.distcode[c&(1<>>24,m=C>>>16&255,g=65535&C,!(_<=l);){if(0===o)break e;o--,c+=r[s++]<>y)],_=C>>>24,m=C>>>16&255,g=65535&C,!(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=Er;break}n.offset=g,n.extra=15&m,n.mode=16203;case 16203:if(n.extra){for(T=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=Er;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=Er;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=yr);break;case 16205:if(0===u)break e;a[i++]=n.length,u--,n.mode=yr;break;case kr:if(n.wrap){for(;l<32;){if(0===o)break e;o--,c|=r[s++]<{if(Cr(e))return ur;let t=e.state;return t.window&&(t.window=null),e.state=null,sr},inflateGetHeader:(e,t)=>{if(Cr(e))return ur;const n=e.state;return 0==(2&n.wrap)?ur:(n.head=t,t.done=!1,sr)},inflateSetDictionary:(e,t)=>{const n=t.length;let r,a,s;return Cr(e)?ur:(r=e.state,0!==r.wrap&&r.mode!==pr?ur:r.mode===pr&&(a=1,a=St(a,t,n,0),a!==r.check)?cr:(s=Ur(e,t,n,n),s?(r.mode=16210,lr):(r.havedict=1,sr)))},inflateInfo:"pako inflate (from Nodeca project)"};var Lr=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 Dr=Object.prototype.toString,{Z_NO_FLUSH:Pr,Z_FINISH:Fr,Z_OK:Gr,Z_STREAM_END:qr,Z_NEED_DICT:Hr,Z_STREAM_ERROR:jr,Z_DATA_ERROR:zr,Z_MEM_ERROR:Vr}=Mt;function Br(e){this.options=Mn.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 Rn,this.strm.avail_out=0;let n=Rr.inflateInit2(this.strm,t.windowBits);if(n!==Gr)throw new Error(Nt[n]);if(this.header=new Lr,Rr.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Un.string2buf(t.dictionary):"[object ArrayBuffer]"===Dr.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=Rr.inflateSetDictionary(this.strm,t.dictionary),n!==Gr)))throw new Error(Nt[n])}function Qr(e,t){const n=new Br(t);if(n.push(e),n.err)throw n.msg||Nt[n.err];return n.result}Br.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?Fr:Pr,"[object ArrayBuffer]"===Dr.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=Rr.inflate(n,i),s===Hr&&a&&(s=Rr.inflateSetDictionary(n,a),s===Gr?s=Rr.inflate(n,i):s===zr&&(s=Hr));n.avail_in>0&&s===qr&&n.state.wrap>0&&0!==e[n.next_in];)Rr.inflateReset(n),s=Rr.inflate(n,i);switch(s){case jr:case zr:case Hr:case Vr:return this.onEnd(s),this.ended=!0,!1}if(o=n.avail_out,n.next_out&&(0===n.avail_out||s===qr))if("string"===this.options.to){let e=Un.utf8border(n.output,n.next_out),t=n.next_out-e,a=Un.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!==Gr||0!==o){if(s===qr)return s=Rr.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},Br.prototype.onData=function(e){this.chunks.push(e)},Br.prototype.onEnd=function(e){e===Gr&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Mn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Kr={Inflate:Br,inflate:Qr,inflateRaw:function(e,t){return(t=t||{}).raw=!0,Qr(e,t)},ungzip:Qr,constants:Mt};const{Deflate:Wr,deflate:Yr,deflateRaw:Zr,gzip:Jr}=Kn,{Inflate:Xr,inflate:$r,inflateRaw:ea,ungzip:ta}=Kr;var na,ra={Deflate:Wr,deflate:Yr,deflateRaw:Zr,gzip:Jr,Inflate:Xr,inflate:$r,inflateRaw:ea,ungzip:ta,constants:Mt},aa=function(e){return E(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=ra.ungzip(e),t.abrupt("return",String.fromCharCode.apply(null,r));case 2:case"end":return t.stop()}}),n)})))};e.ConnectionState=void 0,(na=e.ConnectionState||(e.ConnectionState={})).CONNECTING="CONNECTING",na.OPEN="OPEN",na.CLOSED="CLOSED";var sa,ia=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=qe.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 Le(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 E(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 E(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,aa(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=He,t._ws.onmessage=He,t._ws.onerror=He,t._ws.onclose=function(){t.dispatch("close"),n()},t._ws.close(),t._ws=void 0):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),oa=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?{}: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),ua=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),ca=s((function e(){var t=this;r(this,e),this.promise=new Promise((function(e,n){t.resolve=e,t.reject=n}))})),la=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 Ge(t,{auth:s,sdkState:i,dispatcher:o,logger:u,useFetchCompat:l}),this.websocketClient=new ia(t,{sdkState:i,dispatcher:o,logger:u}),this.websocketClient.on("message",(function(e){if(e.payload.unread_cnt&&a._dispatcher.dispatch(new ua(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 E(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 E(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._sdkState.websocket){t.next=2;break}throw A.connectionRequired;case 2:if(r=new ca,e.ackRequired){s=function(t,n){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(void 0,e)},reject:function(e){return s(e)}}),this.websocketClient.send(e)}catch(e){s(e)}}else try{this.websocketClient.send(e),r.resolve()}catch(e){r.reject(e)}return t.abrupt("return",r.promise);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"send",value:function(e){return E(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 Oe)){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 oa)){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"}(sa||(sa={}));var ha,da=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),fa=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=sa.INITIALIZED,this._lazyCallQueue=[],this.commandRouter=new la(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 da){var n=e.stateType;switch(s._currentConnectionStateType=n,n){case sa.CONNECTED:var r=s._lazyCallQueue;s._lazyCallQueue=[],r.forEach((function(e){return E(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 sa.INITIALIZED:case sa.INTERNAL_DISCONNECTED:case sa.EXTERNAL_DISCONNECTED:case sa.LOGOUT:var a=s._lazyCallQueue;s._lazyCallQueue=[],a.forEach((function(e){return E(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===sa.CONNECTED}},{key:"isLazyCallActivated",get:function(){return this._currentConnectionStateType===sa.CONNECTING||this._currentConnectionStateType===sa.RECONNECTING}},{key:"send",value:function(e){return E(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 oa)){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 ca,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:case 37:t.next=40;break;case 19:if(!(e instanceof Oe)){t.next=39;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 ca,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 39:throw A.invalidCommand;case 40:case"end":return t.stop()}}),n,this)})))}},{key:"forceSend",value:function(e){return E(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}(),pa="sendbird@devicetokens",va=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 ue(ce({type:e.type,token:e.token}))}}]),e}(),_a=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(de,"/").concat(s,"/session_key"),a.method=le.POST,a.params={token:i,expiring_session:!!u},a.requireAuth=!1,a}return s(n)}(Oe),ma=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?"":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)}(oa),ga=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)}(Ue),ya=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o;return r(this,n),(i=t.call(this,e,"LOGI",s)).error=null,i.newKey=null,i.newKey=null!==(o=s.new_key)&&void 0!==o?o:null,i.error=s.error?new A(s.error):null,i}return s(n)}(qe),ka=function(e){i(n,e);var t=f(n);function n(){return r(this,n),t.apply(this,arguments)}return s(n)}(oe),Ea=function(e){return E(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}(),wa=function(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new ba;return E(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(e){return i=null!=e?e:new Error("Halted")},u=function(){s=0};case 4:if(!(-1===n||s=0}},{key:"createRefreshWebsocketCommand",value:function(e,t){return new ma({authToken:e,expiringSession:!0,requestId:t})}},{key:"_refreshSessionKeyByWebSocket",value:function(e){return E(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(ya),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 E(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 _a({userId:this._sdkState.userId,authToken:e,expiringSession:!0}),n.next=3,wa((function(e){return E(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(ga),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 E(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:if(this._currentConnectionStateType!==sa.CONNECTED){t.next=26;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=26;break}if(!n){t.next=26;break}return t.next=14,this._receiveNewAuthToken();case 14:if(!(a=t.sent)){t.next=22;break}return this.auth.authToken=a,t.next=19,this._refreshSessionKey(this.auth.authToken,!1);case 19:this.complete(),t.next=25;break;case 22:return t.next=24,this.clear();case 24:this.close();case 25:return t.abrupt("return");case 26:return t.prev=26,t.next=29,this._refreshSessionKeyByApi(e);case 29:this.complete(),t.next=55;break;case 32:if(t.prev=32,t.t1=t.catch(26),!this._isSessionRelatedError(t.t1)){t.next=54;break}if(!n){t.next=51;break}return t.next=38,this._receiveNewAuthToken();case 38:if(!(s=t.sent)){t.next=46;break}return this.auth.authToken=s,t.next=43,this._refreshSessionKeyByApi(this.auth.authToken);case 43:this.complete(),t.next=49;break;case 46:return t.next=48,this.clear();case 48:this.close();case 49:t.next=52;break;case 51:throw t.t1;case 52:t.next=55;break;case 54:throw t.t1;case 55:case"end":return t.stop()}}),r,this,[[1,8],[26,32]])})))}},{key:"_receiveNewAuthToken",value:function(){var e=this,n=new ca;return Ca((function(){return E(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 E(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,Sa.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(pa);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 E(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(pa,{tokens:this._deviceTokens,lastDeletedAt:this._deviceTokenLastDeletedAt});case 4:case"end":return e.stop()}}),e,this)})))}},{key:"clear",value:function(){return E(this,void 0,void 0,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(),Sa.delete(this),this._deviceTokens=[],this._deviceTokenLastDeletedAt=0,e.next=8,this.saveDeviceToken();case 8:case"end":return e.stop()}}),e,this)})))}}]),a}(se),Ia=function(){function e(){r(this,e),this.type=sa.NONE,this.name="none"}return s(e,[{key:"run",value:function(e){return E(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 E(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,E(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,E(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 E(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 E(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}(),Na=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=sa.LOGOUT,e.name="logout",e}return s(a,[{key:"run",value:function(e){return E(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 La,r);case 6:Ca((function(){return E(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&&e.onDisconnected(a)}));case 1:case"end":return t.stop()}}),n)})))}));case 7:case"end":return n.stop()}}),n)})))}}]),a}(Ia),Ma=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.call(this)).type=sa.EXTERNAL_DISCONNECTED,e.name="externaldisconnected",e}return s(a,[{key:"run",value:function(e){return E(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 E(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 Ra({authToken:n}),a);case 5:case"end":return t.stop()}}),r)})))}},{key:"onReconnect",value:function(e){return E(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 Oa,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onLogout",value:function(e){return E(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)})))}}]),a}(Ia),Aa=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=sa.INTERNAL_DISCONNECTED,t.name="internaldisconnected",t._autoReconnect=!1,t._autoReconnect=s,t}return s(a,[{key:"run",value:function(e){return E(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 Oa,r);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"onConnect",value:function(e,n){return E(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 Ra({authToken:n}),a);case 5:case"end":return t.stop()}}),r)})))}},{key:"onReconnect",value:function(e){return E(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 Oa,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onDisconnectWebSocket",value:function(e){return E(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 Ma,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onLogout",value:function(e){return E(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)})))}}]),a}(Ia),Oa=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=sa.RECONNECTING,e.name="reconnecting",e._callbacks=[],e}return s(a,[{key:"_halt",value:function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=void 0)}},{key:"_flushCallbacks",value:function(e){this._haltConnect=void 0,this._resetConnect=void 0,this._callbacks.forEach((function(t){return t(e)}))}},{key:"run",value:function(e){return E(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 ca,this._callbacks.push((function(e){return e?a.reject(e):a.resolve()})),Ca((function(){return E(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&&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,wa((function(n,r){return E(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===b.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 Ua,r);case 10:Ca((function(){return E(u,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._flushCallbacks(),e.connectionHandlers.forEach((function(e){e.onReconnectSucceeded&&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===b.CONNECTION_CANCELED){n.next=20;break}return n.next=20,e.changeState(new Aa({autoReconnect:!1}),r);case 20:Ca((function(){return E(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&&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 E(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 ca,this._halt(A.connectionCanceled),e.cancelConnectForRetry(),this._callbacks.push((function(){var t=Date.now();e.changeState(new Ra({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 E(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 ca,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 E(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 Aa({autoReconnect:a}),r);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"onDisconnectWebSocket",value:function(e){return E(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,r);case 4:case"end":return t.stop()}}),n,this)})))}},{key:"onLogout",value:function(e){return E(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)})))}}]),a}(Ia),Ua=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=sa.CONNECTED,e.name="connected",e}return s(a,[{key:"onReconnect",value:function(e){return E(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 Oa,r);case 5:case"end":return t.stop()}}),n)})))}},{key:"onDisconnect",value:function(e,n){var r=n.autoReconnect;return E(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 Aa({autoReconnect:r}),a);case 3:case"end":return t.stop()}}),n)})))}},{key:"onDisconnectWebSocket",value:function(e){return E(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 Ma,r);case 3:case"end":return t.stop()}}),n)})))}},{key:"onLogout",value:function(e){return E(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)})))}}]),a}(Ia),Ra=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=sa.CONNECTING,t.name="connecting",t._authToken="",t._callbacks=[],t._authToken=s,t}return s(a,[{key:"_halt",value:function(e){this._haltConnect&&(this._haltConnect(e),this._haltConnect=void 0)}},{key:"_flushCallbacks",value:function(e){this._haltConnect=void 0,this._callbacks.forEach((function(t){return t(e)}))}},{key:"run",value:function(e){return E(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 ca,this._callbacks.push((function(e){return e?a.reject(e):a.resolve()})),n.prev=3,n.next=6,wa((function(n){return E(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===b.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 Ua,r);case 8:Ca((function(){return E(s,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._flushCallbacks(),e.connectionHandlers.forEach((function(t){t.onConnected&&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===b.CONNECTION_CANCELED){n.next=20;break}return n.next=20,e.changeState(new La,r);case 20:Ca((function(){return E(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 E(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 ca,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,i=void 0!==s&&s;return E(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 Aa({autoReconnect:i}),r);case 5:t.next=9;break;case 7:return t.next=9,e.changeState(new Na,r);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"onDisconnectWebSocket",value:function(e){return E(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 Ma,r);case 5:t.next=9;break;case 7:return t.next=9,e.changeState(new Na,r);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"onLogout",value:function(e){return E(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)})))}}]),a}(Ia),La=function(e){i(a,e);var n=f(a);function a(){var e;return r(this,a),(e=n.apply(this,arguments)).type=sa.INITIALIZED,e.name="initialized",e}return s(a,[{key:"onConnect",value:function(e,n){return E(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 Ra({authToken:n}),a);case 3:case"end":return t.stop()}}),r)})))}}]),a}(Ia),Da=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)}(oa),Pa=function(){function e(t){var n=t.pingDelegate,a=t.sdkState,s=t.logger;r(this,e),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;if(!this.sdkState.websocket)throw A.connectionRequired;var n=new Da;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()}),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=void 0),this.pingDelegate.error()}return n}},{key:"pong",value:function(){this._logger.debug("pinger.pong()"),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)}},{key:"refreshTimer",value:function(){var e,t=this;if(!this.sdkState.websocket)throw A.connectionRequired;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=void 0),this._pingTimeoutTimer&&(clearTimeout(this._pingTimeoutTimer),this._pingTimeoutTimer=void 0)}}]),e}(),Fa=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(ce({last_updated_at:e.lastUpdatedAt}))}}]),e}(),Ga=1048576,qa=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*Ga: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 Fa(null!==(i=o.uikit_config)&&void 0!==i?i:{})}return s(e,null,[{key:"payloadify",value:function(e){return ue(ce({emoji_hash:e.emojiHash,file_upload_size_limit:e.uploadSizeLimit/Ga,application_attributes:e.applicationAttributes,premium_feature_list:e.premiumFeatureList,use_reaction:e.useReaction,allow_sdk_log_ingestion:e.allowSdkStatsUpload,uikit_config:e.uikitConfigInfo?Fa.payloadify(e.uikitConfigInfo):null}))}}]),e}(),Ha=function(){function e(t){r(this,e),this._iid="",this._iid=t}return s(e,null,[{key:"payloadify",value:function(e){return{}}}]),e}(),ja=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=le.POST,a.path="".concat(de,"/").concat(s,"/metadata"),a.params={metadata:i},a}return s(n)}(Oe),za=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)}(Ue),Va=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=le.PUT,a.path="".concat(de,"/").concat(s,"/metadata"),a.params={metadata:i,upsert:o},a}return s(n)}(Oe),Ba=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)}(Ue),Qa=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=le.DELETE,a.path="".concat(de,"/").concat(s,"/metadata/").concat(i),a}return s(n)}(Oe),Ka=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=le.DELETE,a.path="".concat(de,"/").concat(s,"/metadata"),a}return s(n)}(Oe),Wa=function(e,t){var n=JSON.parse(JSON.stringify(e));return n._iid&&delete n._iid,t&&t(n),n},Ya=function(e,t){var n=JSON.parse(JSON.stringify(e));return t&&t(n),n},Za=function(e){return{do:function(t){e||t()},throw:function(t){if(!e)throw t}}};e.UserOnlineState=void 0,(ha=e.UserOnlineState||(e.UserOnlineState={})).ONLINE="online",ha.OFFLINE="offline",ha.NON_AVAILABLE="nonavailable";var Ja,Xa=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=fs.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainProfileUrl,"?auth=").concat(e.ekey):this.plainProfileUrl}},{key:"serialize",value:function(){return Wa(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 E(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 Za(this._isValidMetaData(e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new ja({userId:a.userId,metadata:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(za),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 E(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 Za(this._isValidMetaData(e)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Va({userId:s.userId,metadata:e,upsert:n}),t.next=5,i.send(o);case 5:return u=t.sent,c=u.as(Ba),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 E(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 Za(L("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Qa({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 E(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=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Ka({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 ue(ce(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})))}}]),u}(Ha),$a=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),es=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 qa(n),this.user=new Xa(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=fs.of(this._iid);r.sdkState.websocket&&(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 $a({userProfile:this}))}}],[{key:"payloadify",value:function(e){return ue(ce(Object.assign(Object.assign(Object.assign({},Xa.payloadify(e.user)),qa.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}(),ts=function(e){i(a,e);var n=f(a);function a(e,t,s){var i,o,u,c;return r(this,a),(i=n.call(this,e,t,s)).error=null,i.userProfile=new es(e,s),i.deviceTokenLastDeletedAt=null!==(o=s.device_token_last_deleted_at)&&void 0!==o?o:0,i.key=null!==(u=s.key)&&void 0!==u?u:"",i.ekey=null!==(c=s.ekey)&&void 0!==c?c:"",i.error=s.error?new A(s):null,i}return s(a,[{key:"applyTo",value:function(e){return E(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=fs.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("","LOGI",Object.assign({user_id:"",error:!0},e))}}]),a}(qe),ns=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),rs=function(e){i(a,e);var n=f(a);function a(e,t){var s,i,o=t.sdkState,u=t.cacheContext,c=t.connectionHandlers,l=t.sessionManager,h=t.websocketClient,d=t.dispatcher,f=t.logger,p=t.entryState,v=void 0===p?new La:p;return r(this,a),(s=n.call(this))._stateUpdatedAt=0,s._connectingAt=0,s._connectionRequestQueue=[],s._iid=e,s.sdkState=o,s.cacheContext=u,s.connectionHandlers=c,s._sessionManager=l,s._websocketClient=h,s._dispatcher=d,s._logger=f,s._currentState=v,(null===(i=s.sdkState.websocket)||void 0===i?void 0:i.pingerDisabled)||(s._pinger=new Pa({pingDelegate:{send:function(e){return s._websocketClient.send(e)},error:function(e){return s._websocketClient.error(e)}},sdkState:s.sdkState,logger:f})),s._websocketClient.on("open",(function(){s._tryResolveConnectionRequest()})).on("message",(function(e){if("LOGI"===e.code)s.clearLoginTimer(),s._dispatcher.dispatch(e.as(ts))})).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=void 0,s._unresolvedLogi||s._rejectConnectionRequest(A.networkError)}),500)})),s._dispatcher.on((function(e){e instanceof ts&&(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 E(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 da({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 E(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=void 0,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===(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=void 0,(r.error.isSessionKeyExpiredError||r.error.isSessionTokenExpiredError)&&this._dispatcher.dispatch(new Le({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,n,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",a=this.sdkState,s=a.appId,i=a.appVersion,o=a.userId;a.extensions;var u=this.cacheContext.localCacheEnabled,c=this._sessionManager.auth,l=null===(e=this.sdkState.websocket)||void 0===e?void 0:e.compression,h=null!==(t=this.sdkState.extensions)&&void 0!==t?t:{},d=!!h.sb_uikit,f=h.sb_syncmanager?"s".concat(h.sb_syncmanager):"",p=h.sb_uikit?"u".concat(h.sb_uikit):"",v="JS/c".concat(C.SDK_VERSION,"/").concat(f,"/").concat(p);return"".concat(null===(n=this.sdkState.websocket)||void 0===n?void 0:n.host,"/?p=JS&pv=").concat(encodeURIComponent(C.OS_VERSION),"&sv=").concat(encodeURIComponent(C.SDK_VERSION),"&ai=").concat(s).concat(i?"&av=".concat(i):"").concat(c.hasSession?"&key=".concat(encodeURIComponent(c.sessionKey)):"&user_id=".concat(encodeURIComponent(o),"&access_token=").concat(encodeURIComponent(r)),"&pmce=").concat(l?1:0,"&active=1&device_token_types=").concat(encodeURIComponent(["gcm","huawei","apns"].join(",")),"&SB-User-Agent=").concat(v,"&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(u?1:0,"&include_poll_details=1").concat(d?"&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 ns({request:t,features:n,options:a}))}},{key:"_statLogConnection",value:function(e){var t;this._dispatcher.dispatch(new De(new Pe({type:Ae.WEBSOCKET_CONNECT,data:{host_url:null===(t=this.sdkState.websocket)||void 0===t?void 0:t.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,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return E(this,void 0,void 0,t().mark((function r(){var a,s,i=this;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._logiProcessingTimer&&(clearTimeout(this._logiProcessingTimer),this._logiProcessingTimer=void 0,this._rejectConnectionRequest(A.connectionCanceled)),a=this._url(n),s=new ca,this._connectionRequestQueue.push(s),1===this._connectionRequestQueue.length&&(this._connectingAt=Date.now(),this._loginTimer=setTimeout((function(){i._loginTimer=void 0,i._rejectConnectionRequest(A.loginTimeout)}),null===(e=this.sdkState.websocket)||void 0===e?void 0:e.responseTimeout),n&&(this._sessionManager.auth.authToken=n),this._websocketClient.connect(a)),t.abrupt("return",s.promise);case 6:case"end":return t.stop()}}),r,this)})))}},{key:"cancelConnectForRetry",value:function(){this._dispatcher.dispatch(ts.asError(A.connectionRenew))}},{key:"disconnect",value:function(){return E(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 E(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=void 0,this._unresolvedLogi=void 0,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=void 0)}}]),a}(se),as=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._disableWebSocketCloseEventHandling=!1,this._externalCalledWebSocketClose=!1,this._logger=l,this._disableWebSocketCloseEventHandling=d,this._context=new rs(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=void 0),this._websocketEventDispatcherContext&&(this._websocketEventDispatcherContext.close(),this._websocketEventDispatcherContext=void 0)}},{key:"isConnected",get:function(){return this._context.currentState.type===sa.CONNECTED}},{key:"isConnecting",get:function(){var e=this._context.currentState;return e.type===sa.CONNECTING||e.type===sa.RECONNECTING}},{key:"connect",value:function(e){return E(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 E(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 E(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 E(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(e){return E(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 E(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 E(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}(),ss=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)}(Pe),is=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=le.POST,a.path="".concat(xe),a.params={device_id:s,log_entries:i.map((function(e){return Pe.payloadify(e)}))},a}return s(n)}(Oe),os=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"}(Ja||(Ja={}));var us,cs=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=Ja.PENDING,t.isFlushing=!1,t.generation=1,t.lastFlushedAt=0,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===Ja.ENABLED}},{key:"_arrangeStat",value:function(){var e=[];this._collectRequestStat&&e.push.apply(e,_(this.queue.filter((function(e){return e.type===Ae.API_RESULT||e.type===Ae.WEBSOCKET_CONNECT})))),this._collectFeatureLocalCacheStat&&e.push.apply(e,_(this.queue.filter((function(e){return e.type===Ae.FEATURE_LOCALCACHE})))),this.queue=e}},{key:"_save",value:function(){return E(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!==Ja.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 Pe.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 E(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 ss){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 is({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!==b.STAT_LOG_NOT_ALLOWED){e.next=29;break}return e.next=26,this.clear();case 26:this.enabledState=Ja.DISABLED,e.next=30;break;case 29:e.t0.code===b.STAT_UPLOAD_NOT_ALLOWED&&(this.enabledState=Ja.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 E(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 Pe({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,Ea(a);case 13:return t.next=15,this._flush();case 15:this.commandEventContext||(this.commandEventContext=this.dispatcher.on((function(e){if(e instanceof De){var t=e.statLog;s.put(t)}else if(e instanceof ns){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?Ja.ENABLED:Ja.COLLECT_ONLY:s.enabledState=Ja.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 E(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===Ja.DISABLED){t.next=7;break}return e instanceof ss?this._collectFeatureLocalCacheStat&&(r=this.queue.filter((function(t){return t instanceof ss&&t.key===e.key})),a=v(r,1),(s=a[0])?s.data=os(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 E(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=void 0)}}]),a}(se);e.LogLevel=void 0,(us=e.LogLevel||(e.LogLevel={}))[us.NONE=0]="NONE",us[us.VERBOSE=1]="VERBOSE",us[us.DEBUG=2]="DEBUG",us[us.INFO=3]="INFO",us[us.WARN=4]="WARN",us[us.ERROR=5]="ERROR";var ls,hs=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 ue(ce({key:e.key,user_ids:e.userIds,updated_at:e.updatedAt}))}}]),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 ue(ce({key:e.key,value:null!==(t=e.value)&&void 0!==t?t:[]}))}}]),e}(),ws=function(){function e(t){r(this,e),this.secureUrl=null,this.type=null,this.width=0,this.height=0,this.alt=null,this.url=t.url,t.secure_url&&(this.secureUrl=t.secure_url),t.type&&(this.type=t.type),t.width&&(this.width=t.width),t.height&&(this.height=t.height),t.alt&&(this.alt=t.alt)}return s(e,null,[{key:"payloadify",value:function(e){var t,n;return ue(ce({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}))}}]),e}(),Cs=function(){function e(t){r(this,e),this.title=null,this.url=null,this.description=null,this.defaultImage=null,t["og:title"]&&(this.title=t["og:title"]),t["og:url"]&&(this.url=t["og:url"]),t["og:description"]&&(this.description=t["og:description"]),t["og:image"]&&(this.defaultImage=new ws(t["og:image"]))}return s(e,null,[{key:"payloadify",value:function(e){return ue(ce({"og:title":e.title,"og:url":e.url,"og:description":e.description,"og:image":e.defaultImage?ws.payloadify(e.defaultImage):null}))}}]),e}(),xs=function(){function e(t){var n,a;r(this,e),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 ue(ce({name:e.name,volume:e.volume}))}}]),e}(),Ss=function(t){i(a,t);var n=f(a);function a(t,s){var i,o;return r(this,a),(i=n.call(this,t,s)).isBlockedByMe=!1,i.role=D(e.Role,s.role)?s.role:e.Role.NONE,i.isBlockedByMe=null!==(o=s.is_blocked_by_me)&&void 0!==o&&o,i}return s(a,null,[{key:"payloadify",value:function(e){return ue(ce(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{role:e.role,is_blocked_by_me:e.isBlockedByMe})))}}]),a}(Xa);e.ScheduledStatus=void 0,(gs=e.ScheduledStatus||(e.ScheduledStatus={})).PENDING="pending",gs.SENT="sent",gs.FAILED="failed",gs.CANCELED="canceled",function(e){e.PENDING="pending",e.IN_QUEUE="in_queue",e.SENT="sent",e.FAILED="failed",e.CANCELED="canceled",e.REMOVED="removed"}(ys||(ys={}));var Ts,Is=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"}},Ns=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,E,b;r(this,a),(i=n.call(this,t)).channelType=e.ChannelType.BASE,i.parentMessage=null,i.silent=!1,i.isOperatorMessage=!1,i.messageType=e.MessageType.BASE,i.mentionType=null,i.threadInfo=null,i.reactions=[],i.metaArrays=[],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,i.mentionedUsers=s.mentioned_users?s.mentioned_users.map((function(e){return new Xa(i._iid,e)})):null,i.mentionedUserIds=null!==(d=s.mentioned_user_ids)&&void 0!==d?d:null,i.mentionedUsers&&!i.mentionedUserIds&&(i.mentionedUserIds=i.mentionedUsers.map((function(e){return e.userId}))),i.mentionedMessageTemplate=null!==(f=s.mentioned_message_template)&&void 0!==f?f:"",i.threadInfo=s.thread_info?new ms(i._iid,s.thread_info):null,i.reactions=s.reactions?s.reactions.map((function(e){return new Es(e)})):[];var w=null!==(p=s.metaarray)&&void 0!==p?p:{},C=null!==(v=s.metaarray_key_order)&&void 0!==v?v:Object.keys(w).sort((function(e,t){return e.localeCompare(t)}));i.metaArrays=[];for(var x=0;x=t)return this.parentMessage=e,!0}return!1}}],[{key:"payloadify",value:function(e){var t,n,r,s;return ue(ce(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:Is(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 Xa.payloadify(e)})),mentioned_message_template:e.mentionedMessageTemplate,thread_info:e.threadInfo?ms.payloadify(e.threadInfo):null,reactions:e.reactions.map((function(e){return Es.payloadify(e)})),sorted_metaarray:null===(n=e.metaArrays)||void 0===n?void 0:n.map((function(e){return bs.payloadify(e)})),og_tag:e.ogMetaData?Cs.payloadify(e.ogMetaData):null,silent:e.silent,is_op_msg:e.isOperatorMessage,apple_critical_alert_options:e.appleCriticalAlertOptions?xs.payloadify(e.appleCriticalAlertOptions):null,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})))}},{key:"_getParentMessageInfoPayload",value:function(e){return ue(ce({type:e.messageType,ts:e.createdAt,user:e.sender?Ss.payloadify(e.sender):null,message:e.message,file:{url:e.plainUrl,name:e.name,type:e.type,require_auth:e.requireAuth}}))}}]),a}(Ha),Ms=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)).reqId="",i.replyToChannel=!1,i.errorCode=0,i.sender=s.user?new Ss(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(s.scheduled_status&&(i._scheduledStatus=s.scheduled_status),s.scheduled_status){case ys.SENT:case ys.IN_QUEUE:i.sendingStatus=e.SendingStatus.SUCCEEDED;break;case ys.PENDING:i.sendingStatus=e.SendingStatus.SCHEDULED;break;case ys.FAILED:case ys.REMOVED:i.sendingStatus=e.SendingStatus.FAILED;break;case ys.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 ue(ce(Object.assign(Object.assign({},p(o(a),"payloadify",this).call(this,e)),{user:Ss.payloadify(e.sender),req_id:e.reqId,is_reply_to_channel:e.replyToChannel,request_state:e.sendingStatus,error_code:e.errorCode})))}}]),a}(Ns),As=function(){function e(t){var n,a;r(this,e),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 ue(ce({url:"",width:e.maxWidth,height:e.maxHeight,real_width:0,real_height:0}))}}]),e}(),Os={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1},Us=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)},Rs=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)).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;s.parentMessage=Bs(t,ue(ce(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}))))}return s}return s(u,[{key:"getThreadedMessagesByTimestamp",value:function(e,n){return E(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({},Os),n),Za(this.messageId>0&&L("number",e)&&Us(a)).throw(A.invalidParameters),s=wi.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 ue(ce(Object.assign(Object.assign({},p(o(u),"payloadify",this).call(this,e)),{message:e.message,translations:e.translations,parent_message_info:e.parentMessage?p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage):null})))}}]),u}(Ns),Ls=function(){function e(t){var n,a;r(this,e),this.detail={},this.type=null!==(n=t.type)&&void 0!==n?n:"",this.vendor=null!==(a=t.vendor)&&void 0!==a?a:"",t.detail&&L("object",t.detail)&&!Array.isArray(t.detail)&&(this.detail=t.detail)}return s(e,null,[{key:"payloadify",value:function(e){return ue(ce({type:e.type,vendor:e.vendor,detail:e.detail}))}}]),e}();!function(e){e.OPEN="open",e.CLOSED="closed"}(Ts||(Ts={}));var Ds="removed",Ps=function(e){switch(e){case"open":return Ts.OPEN;case"closed":return Ts.CLOSED;default:return null}},Fs=function(e){return!e||!!e.text&&L("string",e.text)},Gs=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 ue(ce(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})))}}]),n}(Ha),qs=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=Ps(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 Gs(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=Ps(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 Gs(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),"number"==typeof r.voter_count&&(this.voterCount=r.voter_count),!0}},{key:"serialize",value:function(){return Wa(this)}}],[{key:"payloadify",value:function(e){return ue(ce(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 Gs.payloadify(e)})),created_by:e.createdBy,allow_user_suggestion:e.allowUserSuggestion,allow_multiple_votes:e.allowMultipleVotes,voted_option_ids:e.votedPollOptionIds})))}}]),n}(Ha),Hs=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 Ls(e)})):[],s._poll=n.poll?new qs(s._iid,n.poll):null,n.parent_message_info){var v=n.parent_message_info;s.parentMessage=Bs(t,ue(ce(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}))))}return s}return s(u,[{key:"getThreadedMessagesByTimestamp",value:function(e,n){return E(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({},Os),n),Za(this.messageId>0&&L("number",e)&&Us(a)).throw(A.invalidParameters),s=wi.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 ue(ce(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 Ls.payloadify(e)})),poll:e._poll?qs.payloadify(e._poll):null,parent_message_info:e.parentMessage?p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage):null})))}}]),u}(Ms),js=function(e){i(n,e);var t=f(n);function n(e,a){var s,i,o,u,c,l;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=null!==(i=a.url)&&void 0!==i?i:"",s.fileName=null!==(o=a.file_name)&&void 0!==o?o:null,s.mimeType=null!==(u=a.file_type)&&void 0!==u?u:null,s.fileSize=null!==(c=a.file_size)&&void 0!==c?c:0,s._requireAuth=null!==(l=a.require_auth)&&void 0!==l&&l;var h=fs.of(s._iid).sessionManager;return s.thumbnails=a.thumbnails?a.thumbnails.map((function(e){return new As(Object.assign(Object.assign({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(s._requireAuth?"?auth=".concat(h.ekey):"")}))})):[],s}return s(n,[{key:"url",get:function(){var e=fs.of(this._iid).sessionManager;return this._requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl}}],[{key:"payloadify",value:function(e){var t;return ue(ce({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}(Ha),zs=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 js(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;s.parentMessage=Bs(t,ue(ce(Object.assign(Object.assign({},d),{created_at:d.ts,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}))))}return s}return s(u,[{key:"getThreadedMessagesByTimestamp",value:function(e,n){return E(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({},Os),n),Za(this.messageId>0&&L("number",e)&&Us(a)).throw(A.invalidParameters),s=wi.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 ue(ce(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 js.payloadify(e)})):null,message_survival_seconds:e.messageSurvivalSeconds,parent_message_info:e.parentMessage?p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage):null})))}},{key:"_isMultipleFilesMessagePayload",value:function(e){var t=e.files;return Array.isArray(t)&&t.length>=2}},{key:"_isMultipleFilesMessageSerializedData",value:function(e){var t=e.fileInfoList;return Array.isArray(t)}}]),u}(Ms),Vs=function(t){switch(t.messageType){case e.MessageType.USER:return Hs.payloadify(t);case e.MessageType.FILE:return t.fileInfoList?zs.payloadify(t):Qs.payloadify(t);case e.MessageType.ADMIN:return Rs.payloadify(t);default:throw A.unknown}},Bs=function(e,t){switch(t.type){case"MESG":return new Hs(e,t);case"FILE":return zs._isMultipleFilesMessagePayload(t)?new zs(e,t):new Qs(e,t);case"ADMM":case"BRDM":return new Rs(e,t)}throw A.unknown},Qs=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;r(this,u),(s=a.call(this,t,n)).messageParams=null,s.plainUrl="",s.requireAuth=!1,s.thumbnails=[],s.messageSurvivalSeconds=-1,s.messageType=e.MessageType.FILE;var E=n.file;s.plainUrl=(null!==(o=null!==(i=null==E?void 0:E.url)&&void 0!==i?i:n.url)&&void 0!==o?o:"").split("?auth=")[0],s.name=null!==(l=null!==(c=null==E?void 0:E.name)&&void 0!==c?c:n.name)&&void 0!==l?l:"File",s.size=null!==(d=null!==(h=null==E?void 0:E.size)&&void 0!==h?h:n.size)&&void 0!==d?d:0,s.data=null!==(p=null!==(f=null==E?void 0:E.data)&&void 0!==f?f:n.custom)&&void 0!==p?p:"",s.type=E?null!==(v=E.type)&&void 0!==v?v:"":null!==(_=n.type)&&void 0!==_?_:"";var b=fs.of(s._iid).sessionManager;if(s.requireAuth=null!==(m=n.require_auth)&&void 0!==m&&m,s.thumbnails=n.thumbnails?n.thumbnails.map((function(e){return new As(Object.assign(Object.assign({},e),{url:"".concat(e.url.split("?auth=")[0]).concat(s.requireAuth?"?auth=".concat(b.ekey):"")}))})):[],s.messageSurvivalSeconds=null!==(g=n.message_survival_seconds)&&void 0!==g?g:-1,n.parent_message_info){var w=n.parent_message_info;s.parentMessage=Bs(t,ue(ce(Object.assign(Object.assign({},w),{created_at:w.ts,message_id:s.parentMessageId,channel_url:s.channelUrl,channel_type:s.channelType,file:w.file,url:null===(y=w.file)||void 0===y?void 0:y.url,require_auth:null===(k=w.file)||void 0===k?void 0:k.require_auth}))))}return s}return s(u,[{key:"url",get:function(){var e=fs.of(this._iid).sessionManager;return this.requireAuth?"".concat(this.plainUrl,"?auth=").concat(e.ekey):this.plainUrl}},{key:"getThreadedMessagesByTimestamp",value:function(e,n){return E(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({},Os),n),Za(this.messageId>0&&L("number",e)&&Us(a)).throw(A.invalidParameters),s=wi.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 ue(ce(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:e.parentMessage?p(o(u),"_getParentMessageInfoPayload",this).call(this,e.parentMessage):null})))}}]),u}(Ms),Ks=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(ce({channel_url:t.channelUrl,files:t.files?Js(t.files):null,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?xs.payloadify(t.appleCriticalAlertOptions):null,silent:t.silent,reply_to_channel:t.isReplyToChannel,parent_message_id:t.parentMessageId?t.parentMessageId:null,req_id:t.reqId,pin_message:t.isPinnedMessage}))})}return s(a)}(oa),Ws=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=le.POST,s.path="".concat(Se(t.channelType),"/").concat(encodeURIComponent(t.channelUrl),"/messages"),s.params=ue(ce({message_type:e.MessageType.FILE,user_id:t.userId,files:t.files?Js(t.files):null,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 As.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?t.parentMessageId:null,apple_critical_alert_options:t.appleCriticalAlertOptions?xs.payloadify(t.appleCriticalAlertOptions):null,reply_to_channel:t.isReplyToChannel,req_id:t.reqId,pin_message:t.isPinnedMessage})),s}return s(a)}(Oe),Ys=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l;r(this,n),(i=t.call(this,e,"FILE",s)).message=s.files&&s.files.length>=2?new zs(e,s):new Qs(e,s);var h=fs.of(e).sdkState;return i.isMentioned=Ie(i.message.mentionType,null!==(c=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})))&&void 0!==c?c:[],h.userId),i.forceUpdateLastMessage=null!==(l=s.force_update_last_message)&&void 0!==l&&l,i}return s(n)}(qe),Zs=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,a)).message=a.files&&a.files.length>=2?new zs(e,a):new Qs(e,a);var l=fs.of(e).sdkState;return s.isMentioned=Ie(s.message.mentionType,null!==(u=null!==(i=s.message.mentionedUserIds)&&void 0!==i?i:null===(o=s.message.mentionedUsers)||void 0===o?void 0:o.map((function(e){return e.userId})))&&void 0!==u?u:[],l.userId),s.forceUpdateLastMessage=null!==(c=a.force_update_last_message)&&void 0!==c&&c,s}return s(n)}(Ue);function Js(e){return e.map((function(e){var t,n;return ue(ce({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 As.payloadify(e)})),require_auth:null===(n=e._uploadedMetaData)||void 0===n?void 0:n.requireAuth}))}))}var Xs;!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"}(Xs||(Xs={}));var $s=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._iid=t,this._sdkState=s,this._requestQueue=o,this._cacheContext=c,this._dispatcher=i,this._dispatcher.on((function(e){e instanceof da&&(a._connectionState=e.stateType)})),this._onlineDetector=u}return s(e,[{key:"_shouldSendThroughWebSocket",get:function(){return this._connectionState===sa.CONNECTED||this._connectionState===sa.CONNECTING||this._connectionState===sa.RECONNECTING}},{key:"_sendFileMessage",value:function(e,n){return E(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 Ks(a),t.next=5,this._requestQueue.send(s);case 5:return i=t.sent,o=i.as(Ys),u=o.message,t.abrupt("return",u);case 10:return c=new Ws(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(Zs),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){var n;return E(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._queueMap.get(e.url))){t.next=58;break}if(a.isResolving){t.next=57;break}a.isResolving=!0,s=[],i=!0,o=y(a.messageQueue),t.prev=7,o.s();case 9:if((u=o.n()).done){t.next=40;break}c=u.value,t.t0=c.state,t.next=t.t0===Xs.PENDING||t.t0===Xs.UPLOADING?14:t.t0===Xs.UPLOADED?17:t.t0===Xs.FAILED?35:38;break;case 14:return i=!1,s.push(c),t.abrupt("break",38);case 17:if(!i){t.next=33;break}return t.prev=18,c.state=Xs.SENDING,t.next=22,this._sendFileMessage(e,c);case 22:return l=t.sent,c.deferred.resolve(l),t.next=26,Ea(100);case 26:t.next=31;break;case 28:t.prev=28,t.t1=t.catch(18),c.deferred.reject(t.t1);case 31:t.next=34;break;case 33:s.push(c);case 34:return t.abrupt("break",38);case 35:return h=null!==(n=c.error)&&void 0!==n?n:A.unknown,c.deferred.reject(h.code===b.REQUEST_CANCELED?A.fileUploadCanceled:h),t.abrupt("break",38);case 38:t.next=9;break;case 40:t.next=45;break;case 42:t.prev=42,t.t2=t.catch(7),o.e(t.t2);case 45:return t.prev=45,o.f(),t.finish(45);case 48:if(d=a.isResolveRequestPending,a.messageQueue=s,a.isResolving=!1,a.isResolveRequestPending=!1,!d){t.next=55;break}return t.next=55,this._resolveMessageQueue(e);case 55:t.next=58;break;case 57:a.isResolveRequestPending=!0;case 58:case"end":return t.stop()}}),r,this,[[7,42,45,48],[18,28]])})))}},{key:"_uploadNextPendingItem",value:function(e){var n;return E(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))){t.next=30;break}if(!(s=a.messageQueue.find((function(e){return e.state===Xs.PENDING})))){t.next=30;break}if(!s.multipleFileUploadInfo){t.next=19;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=13;break}return t.next=11,this._tryUploadNextItemAndUpdateItemState(e,a,s);case 11:t.next=14;break;case 13:s.state=o=0&&e.uploadQueue.splice(n,1)}},{key:"_uploadNextFileForSingleFileItemAndUpdateParams",value:function(e,n,r){var a,s,i;return E(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 vs({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(_s),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 E(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 vs({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(_s),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=void 0,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,a){return E(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 ca,c={requestId:n,params:r,state:Xs.PENDING,deferred:u},ei(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,t){var 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 Xs.PENDING:i.state=Xs.FAILED,i.error=A.requestCanceled,this._resolveMessageQueue(e);break;case Xs.UPLOADING:this._requestQueue.cancel(i.requestId)}}}catch(e){s.e(e)}finally{s.f()}}}}]),e}();function ei(e){return"fileInfoList"in e}var ti,ni={prevResultSize:0,nextResultSize:0,isInclusive:!1,reverse:!1,messageTypeFilter:e.MessageTypeFilter.ALL,customTypesFilter:void 0,senderUserIdsFilter:void 0,replyType:e.ReplyType.NONE,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1,showSubchannelMessagesOnly:!1},ri=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)},ai={replyType:e.ReplyType.NONE,includeReactions:!1,includeThreadInfo:!1,includeMetaArray:!1,includeParentMessageInfo:!1},si=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,(ti=e.MessageEventSource||(e.MessageEventSource={})).UNKNOWN="UNKNOWN",ti.EVENT_MESSAGE_SENT_SUCCESS="EVENT_MESSAGE_SENT_SUCCESS",ti.EVENT_MESSAGE_SENT_FAILED="EVENT_MESSAGE_SENT_FAILED",ti.EVENT_MESSAGE_SENT_PENDING="EVENT_MESSAGE_SENT_PENDING",ti.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",ti.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",ti.EVENT_MESSAGE_DELETED="EVENT_MESSAGE_DELETED",ti.EVENT_MESSAGE_READ="EVENT_MESSAGE_READ",ti.EVENT_MESSAGE_DELIVERED="EVENT_MESSAGE_DELIVERED",ti.EVENT_MESSAGE_REACTION_UPDATED="EVENT_MESSAGE_REACTION_UPDATED",ti.EVENT_MESSAGE_THREADINFO_UPDATED="EVENT_MESSAGE_THREADINFO_UPDATED",ti.EVENT_MESSAGE_OFFSET_UPDATED="EVENT_MESSAGE_OFFSET_UPDATED",ti.REQUEST_MESSAGE="REQUEST_MESSAGE",ti.EVENT_POLL_UPDATED="EVENT_POLL_UPDATED",ti.EVENT_POLL_VOTED="EVENT_POLL_VOTED",ti.SYNC_POLL_CHANGELOGS="SYNC_POLL_CHANGELOGS",ti.REQUEST_RESEND_MESSAGE="REQUEST_RESEND_MESSAGE",ti.REQUEST_THREADED_MESSAGE="REQUEST_THREADED_MESSAGE",ti.REQUEST_MESSAGE_CHANGELOGS="REQUEST_MESSAGE_CHANGELOGS",ti.SYNC_MESSAGE_FILL="SYNC_MESSAGE_FILL",ti.SYNC_MESSAGE_BACKGROUND="SYNC_MESSAGE_BACKGROUND",ti.SYNC_MESSAGE_CHANGELOGS="SYNC_MESSAGE_CHANGELOGS",ti.LOCAL_MESSAGE_PENDING_CREATED="LOCAL_MESSAGE_PENDING_CREATED",ti.LOCAL_MESSAGE_FAILED="LOCAL_MESSAGE_FAILED",ti.LOCAL_MESSAGE_CANCELED="LOCAL_MESSAGE_CANCELED",ti.LOCAL_MESSAGE_RESEND_STARTED="LOCAL_MESSAGE_RESEND_STARTED";var ii,oi=function(t){return t.startsWith("EVENT_")||t.startsWith("LOCAL_MESSAGE_")||t===e.MessageEventSource.SYNC_MESSAGE_FILL||t===e.MessageEventSource.SYNC_MESSAGE_CHANGELOGS||t===e.MessageEventSource.SYNC_POLL_CHANGELOGS},ui=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.messages,i=e.source,o=e.isWebSocketEventComing,u=void 0!==o&&o;return r(this,n),(a=t.call(this)).messages=s,a.source=i,a.isWebSocketEventComing=u,a}return s(n)}(oe),ci=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.messageIds,i=e.source,o=e.isWebSocketEventComing,u=void 0!==o&&o;return r(this,n),(a=t.call(this)).messageIds=s,a.source=i,a.isWebSocketEventComing=u,a}return s(n)}(oe),li=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),hi=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),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=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.event,i=e.source;return r(this,n),(a=t.call(this)).event=s,a.source=i,a}return s(n)}(oe),pi=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=le.GET,a.path="".concat(Se(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)}(Oe),vi=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?Bs(e,Object.assign({},a)):null,s}return s(n)}(Ue),_i=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.prevResultSize,l=e.nextResultSize,h=e.isInclusive,d=e.reverse,f=e.messageTypeFilter,p=e.customTypesFilter,v=e.senderUserIdsFilter,_=e.replyType,m=e.includeMetaArray,g=e.includeReactions,y=e.parentMessageId,k=e.includeThreadInfo,E=e.includeParentMessageInfo,b=e.showSubchannelMessagesOnly,w=e.checkingContinuousMessages;return r(this,n),(a=t.call(this)).method=le.GET,a.path="".concat(Se(s),"/").concat(encodeURIComponent(i),"/messages"),a.params=ue(ce({is_sdk:!0,prev_limit:c,next_limit:l,include:h,reverse:d,message_ts:o,message_id:u,message_type:null!=f?f:null,custom_types:p,sender_ids:v,include_reply_type:_,with_sorted_meta_array:m,include_reactions:g,parent_message_id:y,include_thread_info:k,include_parent_message_info:E,show_subchannel_message_only:b,include_poll_details:!0,checking_continuous_messages:w})),a}return s(n)}(Oe),mi=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 Bs(e,t)})),s}return s(n)}(Ue),gi=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=le.GET,a.path="".concat(Se(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)}(Oe),yi=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 Bs(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)}(Ue),ki=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=le.GET,a.path="".concat(pe,"/").concat(encodeURIComponent(s),"/scheduled_messages/").concat(encodeURIComponent(i)),a.params={},a}return s(n)}(Oe),Ei=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?Bs(e,Object.assign({},a)):null,s}return s(n)}(Ue),bi={},wi=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 $s(e,{sdkState:a,dispatcher:s,requestQueue:i,onlineDetector:o,cacheContext:u}),bi[e]=this}return s(n,[{key:"buildMessageFromSerializedData",value:function(t){var n=Ya(t);switch(n.messageType){case e.MessageType.USER:return new Hs(this._iid,Hs.payloadify(n));case e.MessageType.FILE:return zs._isMultipleFilesMessageSerializedData(n)?new zs(this._iid,zs.payloadify(n)):new Qs(this._iid,Qs.payloadify(n));case e.MessageType.ADMIN:return new Rs(this._iid,Rs.payloadify(n))}throw A.invalidParameters}},{key:"buildUserMessageCreateParamsFromSerializedData",value:function(e,t){return ue(ce({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(ce({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=Ya(e);return new Ss(this._iid,Ss.payloadify(t))}},{key:"getMessage",value:function(e){return E(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 pi(e),t.next=3,this._requestQueue.send(r);case 3:return a=t.sent,s=a.as(vi),i=s.message,t.abrupt("return",i);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"getScheduledMessage",value:function(e){return E(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 ki(e),t.next=3,this._requestQueue.send(r);case 3:return a=t.sent,s=a.as(Ei),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 E(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 _i(Object.assign(Object.assign({channelType:r,channelUrl:n,token:String(a)},ni),s)),e.next=3,this._requestQueue.send(o);case 3:return u=e.sent,c=u.as(mi),l=c.messages,this._dispatcher.dispatch(new ui({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 E(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 _i(Object.assign(Object.assign({channelType:r,channelUrl:n,timestamp:a},ni),s)),e.next=3,this._requestQueue.send(o);case 3:return u=e.sent,c=u.as(mi),l=c.messages,this._dispatcher.dispatch(new ui({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 E(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 _i(Object.assign(Object.assign(Object.assign({channelType:r,channelUrl:n,timestamp:a},ni),s),{checkingContinuousMessages:o})),e.next=3,this._requestQueue.send(u);case 3:return c=e.sent,l=c.payload,h=c.as(mi),d=h.messages,this._dispatcher.dispatch(new ui({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 E(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 _i(Object.assign(Object.assign(Object.assign({channelUrl:n.channelUrl,channelType:n.channelType,timestamp:r},Os),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(mi),l=c.messages,(h=l.slice(1)).forEach((function(e){e.parentMessage=n})),this._dispatcher.dispatch(new ui({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 E(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 gi(ue(ce(Object.assign(Object.assign({channelType:r,channelUrl:n,timestamp:"number"==typeof a?a:null,token:"string"==typeof a?a:null},ai),s)))),e.next=3,this._requestQueue.send(o);case 3:return u=e.sent,c=u.as(yi),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 ui({messages:l,source:i})),p.length>0&&this._dispatcher.dispatch(new ci({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}(),Ci=function(){function t(){r(this,t),this._onPending=He,this._onFailed=He,this._onSucceeded=He}return s(t,[{key:"_trigger",value:function(t){switch(null==t?void 0:t.sendingStatus){case e.SendingStatus.PENDING:0===t.errorCode&&this._onPending(t);break;case e.SendingStatus.SCHEDULED:case e.SendingStatus.SUCCEEDED:this._onSucceeded(t)}}},{key:"_triggerFailed",value:function(t,n){switch(null==n?void 0:n.sendingStatus){case e.SendingStatus.FAILED:case e.SendingStatus.CANCELED:this._onFailed(t,n.scheduledInfo?null: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)).targetMessageId=0;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 ms(e,i),s.targetMessageId=o,s.channelUrl=u,s.channelType=c),s}return s(n)}(Ha),Si={channelUrl:"",channelType:e.ChannelType.BASE,messageId:0,includeReactions:!1,includeMetaArray:!1,includeParentMessageInfo:!1,includeThreadInfo:!1},Ti=function(t){return L("string",t.channelUrl)&&D(e.ChannelType,t.channelType)&&L("number",t.messageId)&&L("boolean",t.includeReactions,!0)&&L("boolean",t.includeMetaArray,!0)&&L("boolean",t.includeParentMessageInfo,!0)&&L("boolean",t.includeThreadInfo,!0)},Ii=function(){function e(t,n){var a;r(this,e),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}(),Ni=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=le.GET,a.path="".concat(ge,"/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)}(Oe),Mi=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 Bs(e,t)})),s.hasNext=a.has_next,s.nextToken=a.end_cursor,s.totalCount=a.total_count,s}return s(n)}(Ue);e.MessageSearchOrder=void 0,(ii=e.MessageSearchOrder||(e.MessageSearchOrder={})).SCORE="score",ii.TIMESTAMP="ts";var Ai,Oi,Ui,Ri=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 E(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=fs.of(this._iid),r=n.requestQueue,a=new Ni(ce(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(Mi),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}(Ii),Li=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}(Ii),Di=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 E(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=wi.of(this._iid),e.next=7,n.getMessagesByTimestamp(this.channelUrl,this.channelType,this._edge,ce({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}(Li),Pi={channelUrl:"",scheduledMessageId:0},Fi=function(e){return L("string",e.channelUrl)&&""!==e.channelUrl&&L("number",e.scheduledMessageId)&&e.scheduledMessageId>0},Gi=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.apply(this,arguments))._onFileUploaded=He,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}(Ci),qi=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 wi(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 E(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({},Si),e),Za(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 E(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({},Pi),e),Za(Fi(r)).throw(A.invalidParameters),t.abrupt("return",this._manager.getScheduledMessage(r));case 3:case"end":return t.stop()}}),n,this)})))}}]),a}(ps),Hi=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=le.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)}(Oe),ji=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 qs(e,a),s}return s(n)}(Ue),zi=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=le.GET,a.path="".concat(be,"/").concat(encodeURIComponent(o)),a.params={channel_url:s,channel_type:i},a}return s(n)}(Oe),Vi=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 qs(e,a),s}return s(n)}(Ue),Bi=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=le.GET,a.path="".concat(be,"/").concat(encodeURIComponent(o),"/options/").concat(encodeURIComponent(u)),a.params={channel_url:s,channel_type:i},a}return s(n)}(Oe),Qi=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 Gs(e,a),s}return s(n)}(Ue),Ki=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=le.GET,a.path="".concat(Se(s),"/").concat(encodeURIComponent(i),"/polls/changelogs"),a.params=ue({change_ts:o,token:u}),a}return s(n)}(Oe),Wi=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 new qs(e,t)}(e,t)})),s.deletedPollIds=a.deleted.map((function(e){return e})),s.hasMore=a.has_more,s.nextToken=a.next,s}return s(n)}(Ue),Yi={title:"",optionTexts:[],data:void 0,allowUserSuggestion:void 0,allowMultipleVotes:void 0,closeAt:-1},Zi=function(e){return L("string",e.title)&&(t=e.optionTexts,F("string",t)&&t.every((function(e){return""!==e.trim()})))&&Fs(e.data)&&L("boolean",e.allowUserSuggestion,!0)&&L("boolean",e.allowMultipleVotes,!0)&&L("number",e.closeAt,!0);var t},Ji={channelUrl:"",channelType:e.ChannelType.BASE,pollId:0,pollOptionId:0},Xi=function(t){return L("string",t.channelUrl)&&""!==t.channelUrl&&D(e.ChannelType,t.channelType)&&L("number",t.pollId)&&t.pollId>0&&L("number",t.pollOptionId)&&t.pollOptionId>0},$i={channelUrl:"",channelType:e.ChannelType.BASE,pollId:0},eo=function(t){return L("string",t.channelUrl)&&""!==t.channelUrl&&D(e.ChannelType,t.channelType)&&L("number",t.pollId)},to={},no=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,to[e]=this}return s(n,[{key:"buildPollFromSerializedData",value:function(e){var t=Ya(e);return new qs(this._iid,qs.payloadify(t))}},{key:"get",value:function(e){return E(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 Za(eo(e)).throw(A.invalidParameters),r=new zi(Object.assign({},e)),t.next=4,this._requestQueue.send(r);case 4:return a=t.sent,s=a.as(Vi),i=s.poll,t.abrupt("return",i);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"create",value:function(e){return E(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 Za(Zi(e)).throw(A.invalidParameters),r=new Hi(Object.assign({},e)),t.next=4,this._requestQueue.send(r);case 4:return a=t.sent,s=a.as(ji),i=s.poll,t.abrupt("return",i);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"getOption",value:function(e){return E(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 Za(Xi(e)).throw(A.invalidParameters),r=new Bi(Object.assign({},e)),t.next=4,this._requestQueue.send(r);case 4:return a=t.sent,s=a.as(Qi),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 E(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 Ki(ce({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(Wi),c=u.updatedPolls,l=u.deletedPollIds,h=u.hasMore,d=u.nextToken,c.length>0&&this._dispatcher.dispatch(new hi({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 to[e]}}]),n}(),ro=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})),ao=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})),so=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=le.GET,a.path=be,a.params={channel_url:s,channel_type:i,token:o,limit:u},a}return s(n)}(Oe),io=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 qs(e,t)})),s.token=a.next,s}return s(n)}(Ue),oo=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 E(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=fs.of(this._iid),r=n.requestQueue,a=new so(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(io),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}(Li),uo=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=le.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)}(Oe),co=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 Xa(e,t)})),s.token=a.next,s}return s(n)}(Ue),lo=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 E(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=fs.of(this._iid),r=n.requestQueue,a=new uo(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(co),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}(Li),ho=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 no(e,{sdkState:n,dispatcher:r,sessionManager:s,requestQueue:i,logger:u,onlineDetector:c,cacheContext:l})}},{key:"create",value:function(e){return E(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({},Yi),e),Za(Zi(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 E(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({},$i),e),Za(eo(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 E(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({},Ji),e),Za(Xi(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}(ps),fo={profileImage:void 0,profileUrl:void 0,nickname:void 0},po=function(e){return q(e.profileImage,!0)&&L("string",e.profileUrl,!0)&&L("string",e.nickname,!0)},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.onSessionExpired=He,this.onSessionTokenRequired=function(e){return e(null)},this.onSessionError=He,this.onSessionRefreshed=He,this.onSessionClosed=He}))),_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.onConnected=He,this.onReconnectStarted=He,this.onReconnectSucceeded=He,this.onReconnectFailed=He,this.onDisconnected=He}))),mo=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=He,this.onTotalUnreadMessageCountUpdated=He}))),go="GroupChannel",yo=100,ko="Message";e.GroupChannelListOrder=void 0,(Ai=e.GroupChannelListOrder||(e.GroupChannelListOrder={})).LATEST_LAST_MESSAGE="latest_last_message",Ai.CHRONOLOGICAL="chronological",Ai.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",Ai.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.PublicGroupChannelListOrder=void 0,(Oi=e.PublicGroupChannelListOrder||(e.PublicGroupChannelListOrder={})).CHRONOLOGICAL="chronological",Oi.CHANNEL_NAME_ALPHABETICAL="channel_name_alphabetical",Oi.METADATA_VALUE_ALPHABETICAL="metadata_value_alphabetical",e.ScheduledMessageListOrder=void 0,(Ui=e.ScheduledMessageListOrder||(e.ScheduledMessageListOrder={})).CREATED_AT="created_at",Ui.SCHEDULED_AT="scheduled_at";var Eo,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"];default:return["-lastMessageUpdatedAt","-createdAt","syncIndex"]}},wo=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 Ms))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 Ms&&t.parentMessageId>0&&!t.replyToChannel)return!1}return!0}}]),t}();!function(e){e.CHANNEL_LATEST="channel_latest",e.NEWEST_CHILD_MESSAGE="newest_child_message"}(Eo||(Eo={}));var Co,xo=function(e){switch(e){case Eo.CHANNEL_LATEST:return["channelUrl","-createdAt","-messageId"];case Eo.NEWEST_CHILD_MESSAGE:return["channelUrl","-parentMessageId","-createdAt","-messageId"]}},So={data:void 0,customType:void 0,mentionType:e.MentionType.USERS,mentionedUserIds:void 0,mentionedUsers:void 0,mentionedMessageTemplate:void 0,metaArrays:void 0,parentMessageId:void 0,isReplyToChannel:!1,pushNotificationDeliveryOption:void 0,appleCriticalAlertOptions:void 0,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(Xa,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)},Io=function(e){return{isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption,pollId:e.pollId}},No=Object.assign(Object.assign({},So),{message:"",translationTargetLanguages:void 0,pollId:void 0}),Mo=function(e){var t;return ue(ce({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)}))},Ao=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"}(Co||(Co={}));var Oo,Uo,Ro=function(e){return"undefined"!=typeof window&&"Blob"in window&&"undefined"!=typeof Blob&&e instanceof Blob},Lo=function(e){return e===Co.BLOB||e===Co.FILE},Do=function(e){return{file:e.file,fileKey:e.fileKey,fileType:e.fileType,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption}},Po=Object.assign(Object.assign({},So),{file:void 0,fileKey:void 0,fileUrl:void 0,fileName:void 0,fileType:void 0,fileSize:void 0,mimeType:void 0,thumbnailSizes:void 0,requireAuth:!1}),Fo=function(e,t){var n;return e.messageParams?(!e.url&&q(t)&&(e.messageParams.file=t),e.messageParams):ue(ce({data:e.data,customType:e.customType,mentionType:e.mentionType,mentionedUsers:e.mentionedUsers,mentionedUserIds:e.mentionedUserIds,metaArrays:e.metaArrays,parentMessageId:e.parentMessageId,appleCriticalAlertOptions:e.appleCriticalAlertOptions,file:t,fileUrl:e.url,fileName:e.name,fileSize:e.size,mimeType:e.type,thumbnailSizes:null===(n=e.thumbnails)||void 0===n?void 0:n.map((function(e){return{maxWidth:e.width,maxHeight:e.height}}))}))},Go=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})))},qo=function(){return"undefined"!=typeof document&&"undefined"!=typeof navigator&&"ReactNative"!==navigator.product},Ho=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"}(Oo||(Oo={})),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"}(Uo||(Uo={}));var jo,zo={},Vo=function(){function e(t){var n=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return r(this,e),this._state=Oo.PROCESSING,this._queue=[],this._activationQueue=[],zo[t]&&!a.forceCreate||(this.nodeId=Ho(),this.key=t,qo()&&(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 Uo.NEWNODE:n._sendSync();break;case Uo.CLAIM_HOST:n._sendSync(),n._hostId=r;break;case Uo.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:Uo.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 Uo.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 Uo.REQUEST_LOCK:n._requestLock(t);break;case Uo.ACQUIRE_LOCK:var d=n._queue.find((function(e){return e.requestId===a}));n._acquire(d);break;case Uo.RELEASE_LOCK:n._release(a)}})),window.addEventListener("beforeunload",(function(){n._send(Uo.REMOVENODE)}))),zo[t]=this),zo[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==Oo.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:Ho(),key:this.key,op:e,data:n.data,ts:Date.now()};return qo()&&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(Uo.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(Uo.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(Uo.SYNC_HOST,{data:{currentItemRequestId:null===(e=this._currentItem)||void 0===e?void 0:e.requestId,queue:this._queue.map((function(e){return{nodeId:e.nodeId,requestId:e.requestId,ts:e.ts}}))}})}},{key:"_waitUntilSyncCompleted",value:function(){return E(this,void 0,void 0,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=Oo.DONE,this._activationQueue.forEach((function(e){return e()})),this._activationQueue=[])}},{key:"registerNode",value:function(){this._send(Uo.NEWNODE),this._waitSync()}},{key:"claimHost",value:function(){this._hostId=this.nodeId,this._send(Uo.CLAIM_HOST),this._waitSync()}},{key:"lock",value:function(){return E(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(Uo.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}(),Bo=Object.assign(Object.assign({},No),{scheduledAt:void 0}),Qo=Object.assign(Object.assign({},So),{scheduledAt:0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Ko=Object.assign(Object.assign({},So),{fileInfoList:[]}),Wo=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})))},Yo="UnsentMessage",Zo={},Jo=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,Zo[e]=d(s),s._mutex=new Vo("unsendmessagecache.lock"),s}return s(a,[{key:"collection",get:function(){var e=this._cacheContext.nestdb,t=null==e?void 0:e.collection(Yo);if(!t)throw A.databaseError;return t}},{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 Hs?(e.messageParams&&(n.messageParams=Io(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=(t=e.scheduledInfo.scheduledMessageParams,Object.assign(Object.assign({},Io(t)),{scheduledAt:t.scheduledAt})))):e instanceof Qs?(e.messageParams&&(n.messageParams=Do(e.messageParams)),e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams&&(n.scheduledInfo.scheduledMessageParams=function(e){return Object.assign(Object.assign({},Do(e)),{scheduledAt:e.scheduledAt})}(e.scheduledInfo.scheduledMessageParams))):e instanceof zs&&e.messageParams&&(n.messageParams=function(e){return ue({fileInfoList:e.fileInfoList,isReplyToChannel:e.isReplyToChannel,pushNotificationDeliveryOption:e.pushNotificationDeliveryOption})}(e.messageParams)),n}},{key:"_deserialize",value:function(e){return e=Object.assign(Object.assign({},e),{messageId:parseInt(e.messageId)}),wi.of(this._iid).buildMessageFromSerializedData(e)}},{key:"_deserializeWithMessageCreateParams",value:function(e){var n,r,a;return E(this,void 0,void 0,t().mark((function s(){var i,o,u,c,l,h,d,f=this;return t().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:if(i=wi.of(this._iid),o=this._deserialize(e),!e.messageParams){s.next=32;break}if(!(o instanceof Hs)){s.next=8;break}u=e.messageParams,o.messageParams=i.buildUserMessageCreateParamsFromSerializedData(u,o),s.next=32;break;case 8:if(!(o instanceof Qs)){s.next=26;break}if(!(c=e.messageParams).fileKey||"string"!=typeof c.fileKey||!Lo(null!==(n=c.fileType)&&void 0!==n?n:"")){s.next=23;break}return s.next=13,this.collection.getBlob(c.fileKey);case 13:if(s.t1=r=s.sent,s.t0=null!==s.t1,!s.t0){s.next=17;break}s.t0=void 0!==r;case 17:if(!s.t0){s.next=21;break}s.t2=r,s.next=22;break;case 21:s.t2=void 0;case 22:c.file=s.t2;case 23:o.messageParams=i.buildFileMessageCreateParamsFromSerializedData(c,o),s.next=32;break;case 26:if(!(o instanceof zs)){s.next=32;break}if(!(l=e.messageParams)||!l.fileInfoList){s.next=32;break}return o.messageParams=i.buildMultipleFilesMessageCreateParamsFromSerializedData(l,o),s.next=32,Promise.all(o.messageParams.fileInfoList.map((function(e){return E(f,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:if("string"!=typeof(null===(r=e._uploadedMetaData)||void 0===r?void 0:r.fileKey)||!Lo(null!==(s=null===(a=e._uploadedMetaData)||void 0===a?void 0:a.fileType)&&void 0!==s?s:"")){t.next=13;break}return t.next=3,this.collection.getBlob(e._uploadedMetaData.fileKey);case 3:if(t.t1=i=t.sent,t.t0=null!==t.t1,!t.t0){t.next=7;break}t.t0=void 0!==i;case 7:if(!t.t0){t.next=11;break}t.t2=i,t.next=12;break;case 11:t.t2=void 0;case 12:e.file=t.t2;case 13:case"end":return t.stop()}}),n,this)})))})));case 32:if(!(o.scheduledInfo&&e.scheduledInfo&&e.scheduledInfo.scheduledMessageParams)){s.next=54;break}if(!(o instanceof Hs)){s.next=38;break}h=e.scheduledInfo.scheduledMessageParams,o.scheduledInfo.scheduledMessageParams=i.buildScheduledUserMessageCreateParamsFromSerializedData(h,o),s.next=54;break;case 38:if(!(o instanceof Qs)){s.next=54;break}if(!(d=e.scheduledInfo.scheduledMessageParams).fileKey||"string"!=typeof d.fileKey||"string"!=typeof d.fileType||!Lo(d.fileType)){s.next=53;break}return s.next=43,this.collection.getBlob(d.fileKey);case 43:if(s.t4=a=s.sent,s.t3=null!==s.t4,!s.t3){s.next=47;break}s.t3=void 0!==a;case 47:if(!s.t3){s.next=51;break}s.t5=a,s.next=52;break;case 51:s.t5=void 0;case 52:d.file=s.t5;case 53:o.scheduledInfo.scheduledMessageParams=i.buildScheduledFileMessageCreateParamsFromSerializedData(d,o);case 54:return s.abrupt("return",o);case 55:case"end":return s.stop()}}),s,this)})))}},{key:"_getFileInfoBlobKey",value:function(e,t){return"".concat(e,".").concat(t)}},{key:"get",value:function(e){return E(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",void 0);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"fetch",value:function(e){var n=e.channelUrl,r=e.filter,a=void 0===r?new wo:r,s=e.order,i=void 0===s?Eo.CHANNEL_LATEST:s,o=e.sendingStatus,u=e.backward,c=void 0!==u&&u,l=e.parentMessageId;return E(this,void 0,void 0,t().mark((function e(){var r,s,u,h,d,f=this;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.localCacheEnabled){e.next=13;break}return r=xo(i),s={"/where":function(e){return!!(i!==Eo.NEWEST_CHILD_MESSAGE||l&&0!==e.parentMessageId&&e.parentMessageId===l)&&a.match(f._deserialize(e))}},n&&(s.channelUrl=n),o&&(s.sendingStatus=o),u={where:s,index:r,backward:c},e.next=8,this.collection.query(u);case 8:return h=e.sent,e.next=11,h.fetch({});case 11:return d=e.sent,e.abrupt("return",Promise.all(d.map((function(e){return E(f,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 wo;return E(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:Eo.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 E(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 E(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 Qs||e instanceof zs)){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 E(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 E(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(r=[],!(e.threadInfo&&e.threadInfo.replyCount>0)){t.next=5;break}return t.next=4,this.getAllChildMessages(e);case 4:r=t.sent;case 5:if(!(r.length>0)){t.next=9;break}return r.forEach((function(t){return t.applyParentMessage(e)})),t.next=9,this.upsert(r);case 9:case"end":return t.stop()}}),n,this)})))})));case 3:case"end":return n.stop()}}),n,this)})))}},{key:"remove",value:function(e){return E(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 E(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 E(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 E(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 Qs)){n.next=19;break}if(!e.messageParams){n.next=9;break}if(!(r=e.messageParams).file||!Ro(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=Co.BLOB;case 9:if(!e.scheduledInfo||!e.scheduledInfo.scheduledMessageParams){n.next=17;break}if(!(s=e.scheduledInfo.scheduledMessageParams).file||!Ro(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=Co.BLOB;case 17:n.next=24;break;case 19:if(!(e instanceof zs)){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 E(u,void 0,void 0,t().mark((function a(){var s;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!n.file||!Ro(n.file)){t.next=7;break}return t.next=3,this.collection.saveBlob(n.file,this._getFileInfoBlobKey(e.reqId,r));case 3:s=t.sent,n._uploadedMetaData||(n._uploadedMetaData={}),n._uploadedMetaData.fileKey=s,n._uploadedMetaData.fileType=Co.BLOB;case 7:case"end":return t.stop()}}),a,this)})))})));case 24:case"end":return n.stop()}}),n,this)})))}}],[{key:"of",value:function(e){return Zo[e]}}]),a}(Ha),Xo=function(n,r){return function(a,s){if(1===a)n.clear().then((function(){r.clear().then((function(){(function(n){return E(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:go,keyName:"url",index:[bo(e.GroupChannelListOrder.LATEST_LAST_MESSAGE),bo(e.GroupChannelListOrder.CHRONOLOGICAL),bo(e.GroupChannelListOrder.CHANNEL_NAME_ALPHABETICAL)]},{collectionName:ko,keyName:"messageId",index:[xo(Eo.CHANNEL_LATEST),xo(Eo.NEWEST_CHILD_MESSAGE)]},{collectionName:Yo,keyName:"reqId",index:[xo(Eo.CHANNEL_LATEST),xo(Eo.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()}},$o={},eu=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,$o[e]=d(s),s}return s(a,[{key:"collection",get:function(){var e=this._cacheContext.nestdb;return Za(!!e).throw(A.databaseError),e.collection(ko)}},{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)}),wi.of(this._iid).buildMessageFromSerializedData(e)}},{key:"get",value:function(e){return E(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",void 0);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?yo:a,i=e.filter,o=void 0===i?new wo:i,u=e.order,c=void 0===u?Eo.CHANNEL_LATEST:u,l=e.backward,h=void 0!==l&&l,d=e.parentMessageId,f=e.isPollOnly,p=void 0!==f&&f,v=e.exactMatch,_=void 0!==v&&v,m=e.inclusive,g=void 0===m||m;return E(this,void 0,void 0,t().mark((function e(){var a,i,u,l,f=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 Eo.CHANNEL_LATEST:if(_&&e.createdAt!==r)return!1;if(h){if(g&&e.createdAtr||!g&&e.createdAt>=r)return!1;break;case Eo.NEWEST_CHILD_MESSAGE:if(!d||0===e.parentMessageId||e.parentMessageId!==d)return!1}return!(p&&!e._poll)&&o.match(f._deserialize(e))}},index:a,backward:h},e.next=5,this.collection.query(i);case 5:return u=e.sent,e.next=8,u.fetch({limit:null!=s?s:void 0});case 8:return l=e.sent,e.abrupt("return",Promise.all(l.map((function(e){return E(f,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._deserialize(e));case 1:case"end":return t.stop()}}),n,this)})))}))));case 10:return e.abrupt("return",[]);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"getAllChildMessages",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new wo;return E(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:Eo.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 E(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 E(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 E(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)&&e.threadInfo.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 E(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 E(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(Eo.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 E(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(Eo.CHANNEL_LATEST)});case 3:case"end":return t.stop()}}),r,this)})))}},{key:"clear",value:function(){return E(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 E(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(Eo.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 E(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 E(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 Qs&&e.messageParams)){t.next=7;break}if(!(r=e.messageParams).file||!Ro(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 E(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 $o[e]}}]),a}(Ha),tu=function(){return"undefined"!=typeof document?document.visibilityState:"visible"},nu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.getVisibilityState,i=void 0===s?tu: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._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=void 0),this.dispatch("resume")):"hidden"!==this._currentState&&(this._pauseDelayTimer=setTimeout((function(){e._pauseDelayTimer=void 0,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),ru=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 E(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:le.GET,mode:"no-cors"}).then((function(){return e(!0)})).catch((function(){return e(!1)}))})));case 5:case"end":return e.stop()}}),e,this)})))}}]),e}(),au=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),su={},iu=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,su[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 da)switch(e.stateType){case sa.CONNECTED:a._isProcessingAutoResend||a.processAutoResendRegisteredPendingMessages().then((function(){return a._processNextAutoResend()}));break;case sa.INTERNAL_DISCONNECTED:case sa.EXTERNAL_DISCONNECTED:a._isProcessingAutoResend=!1}}))}return s(n,[{key:"processNonAutoResendRegisteredPendingMessages",value:function(){return E(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=b.ACK_TIMEOUT,this._dispatcher.dispatch(new ui({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 E(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 ui({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 E(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=Jo.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 E(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 au({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 su[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"}(jo||(jo={}));var ou,uu=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 Xa(e,r),blockee:new Xa(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 Xa(e,t)})):[]}}}]),e}(),cu=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,(ou=e.GroupChannelEventSource||(e.GroupChannelEventSource={})).UNKNOWN="UNKNOWN",ou.EVENT_CHANNEL_CREATED="EVENT_CHANNEL_CREATED",ou.EVENT_CHANNEL_UPDATED="EVENT_CHANNEL_UPDATED",ou.EVENT_CHANNEL_DELETED="EVENT_CHANNEL_DELETED",ou.EVENT_CHANNEL_READ="EVENT_CHANNEL_READ",ou.EVENT_CHANNEL_DELIVERED="EVENT_CHANNEL_DELIVERED",ou.EVENT_CHANNEL_INVITED="EVENT_CHANNEL_INVITED",ou.EVENT_CHANNEL_JOINED="EVENT_CHANNEL_JOINED",ou.EVENT_CHANNEL_LEFT="EVENT_CHANNEL_LEFT",ou.EVENT_CHANNEL_ACCEPTED_INVITE="EVENT_CHANNEL_ACCEPTED_INVITE",ou.EVENT_CHANNEL_DECLINED_INVITE="EVENT_CHANNEL_DECLINED_INVITE",ou.EVENT_CHANNEL_OPERATOR_UPDATED="EVENT_CHANNEL_OPERATOR_UPDATED",ou.EVENT_CHANNEL_BANNED="EVENT_CHANNEL_BANNED",ou.EVENT_CHANNEL_MUTED="EVENT_CHANNEL_MUTED",ou.EVENT_CHANNEL_UNMUTED="EVENT_CHANNEL_UNMUTED",ou.EVENT_CHANNEL_FROZEN="EVENT_CHANNEL_FROZEN",ou.EVENT_CHANNEL_UNFROZEN="EVENT_CHANNEL_UNFROZEN",ou.EVENT_CHANNEL_HIDDEN="EVENT_CHANNEL_HIDDEN",ou.EVENT_CHANNEL_UNHIDDEN="EVENT_CHANNEL_UNHIDDEN",ou.EVENT_CHANNEL_RESET_HISTORY="EVENT_CHANNEL_RESET_HISTORY",ou.EVENT_CHANNEL_TYPING_STATUS_UPDATE="EVENT_CHANNEL_TYPING_STATUS_UPDATE",ou.EVENT_CHANNEL_MEMBER_COUNT_UPDATED="EVENT_CHANNEL_MEMBER_COUNT_UPDATED",ou.EVENT_MESSAGE_SENT="EVENT_MESSAGE_SENT",ou.EVENT_MESSAGE_RECEIVED="EVENT_MESSAGE_RECEIVED",ou.EVENT_MESSAGE_UPDATED="EVENT_MESSAGE_UPDATED",ou.EVENT_PINNED_MESSAGE_UPDATED="EVENT_PINNED_MESSAGE_UPDATED",ou.REQUEST_CHANNEL="REQUEST_CHANNEL",ou.REQUEST_CHANNEL_CHANGELOGS="REQUEST_CHANNEL_CHANGELOGS",ou.REFRESH_CHANNEL="REFRESH_CHANNEL",ou.CHANNEL_LASTACCESSEDAT_UPDATED="CHANNEL_LASTACCESSEDAT_UPDATED",ou.SYNC_CHANNEL_BACKGROUND="SYNC_CHANNEL_BACKGROUND",ou.SYNC_CHANNEL_CHANGELOGS="SYNC_CHANNEL_CHANGELOGS";var lu,hu=function(t){return t.startsWith("EVENT_")||t===e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS||t===e.GroupChannelEventSource.REFRESH_CHANNEL},du=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channels,i=e.source,o=e.isWebSocketEventComing,u=void 0!==o&&o,c=e.data,l=void 0===c?null:c;return r(this,n),(a=t.call(this)).channels=s,a.source=i,a.isWebSocketEventComing=u,a.data=l,a}return s(n)}(oe),fu=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.channelUrls,i=e.source,o=e.isWebSocketEventComing,u=void 0!==o&&o;return r(this,n),(a=t.call(this)).channelUrls=s,a.source=i,a.isWebSocketEventComing=u,a}return s(n)}(oe),pu=function(e){i(n,e);var t=f(n);function n(){return r(this,n),t.call(this)}return s(n)}(oe),vu=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 uu(s),i}return s(n)}(qe),_u=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.userId,i=e.nickname,o=e.profileUrl,u=e.profileImage,c=e.preferredLanguages;return r(this,n),(a=t.call(this)).method=le.PUT,a.path="".concat(de,"/").concat(encodeURIComponent(s)),a.params=ue(ce({nickname:i,profile_url:o,profile_file:u,preferred_languages:c})),a}return s(n)}(Oe),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)).user=new Xa(e,Object.assign({},a)),s}return s(n)}(Ue),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=le.POST,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push/apns"),a.params={apns_device_token:i,always_push:!0},a}return s(n)}(Oe),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=le.POST,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push/gcm"),a.params={gcm_reg_token:i,always_push:!0},a}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=le.DELETE,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push/apns/").concat(encodeURIComponent(i)),a}return s(n)}(Oe),Eu=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=le.DELETE,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push/gcm/").concat(encodeURIComponent(i)),a}return s(n)}(Oe),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=le.DELETE,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push/apns"),a}return s(n)}(Oe),wu=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=le.DELETE,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push/gcm"),a}return s(n)}(Oe),Cu=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=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push/").concat(encodeURIComponent(i),"/device_tokens"),a.params={created_ts:u,token:o},a}return s(n)}(Oe),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)}(Ue),Su=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=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/channel_invitation_preference"),a}return s(n)}(Oe),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)}(Ue),Iu=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=le.PUT,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/channel_invitation_preference"),a.params={auto_accept:i},a}return s(n)}(Oe),Nu=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)}(Ue),Mu=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=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push_preference"),a}return s(n)}(Oe),Au=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)}(Ue),Ou=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=le.PUT,a.path="".concat(de,"/").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)}(Oe),Uu=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)}(Ue),Ru=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=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push_preference"),a}return s(n)}(Oe),Lu=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)}(Ue),Du=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=le.PUT,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push_preference"),a.params={snooze_enabled:i,snooze_start_ts:o,snooze_end_ts:u},a}return s(n)}(Oe),Pu=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)}(Ue),Fu=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=le.POST,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/block"),a.params={target_id:i},a}return s(n)}(Oe),Gu=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=le.DELETE,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/block/").concat(encodeURIComponent(i)),a}return s(n)}(Oe),qu=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=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push_preference"),a}return s(n)}(Oe),Hu=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)}(Ue),ju=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=le.PUT,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push_preference"),a.params={push_trigger_option:i},a}return s(n)}(Oe),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)).pushTriggerOption=a.push_trigger_option,s}return s(n)}(Ue),Vu=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=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push/template"),a}return s(n)}(Oe),Bu=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)}(Ue),Qu=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=le.PUT,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push/template"),a.params={name:i},a}return s(n)}(Oe),Ku=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)}(Ue),Wu=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=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/friends/changelogs"),a.params={token:i},a}return s(n)}(Oe),Yu=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 Xa(e,t)})),updatedUsers:a.updated.map((function(t){return new Xa(e,t)})),deletedUserIds:a.deleted,hasMore:a.has_more,token:a.next},s}return s(n)}(Ue),Zu=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=le.PUT,a.path="".concat(de,"/").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)}(Oe),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)).friendDiscoveryRequestId=a.friend_discovery_request_id,s}return s(n)}(Ue),Xu=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=le.DELETE,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/friend_discoveries"),a.params={friend_discovery_keys:i},a}return s(n)}(Oe),$u=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=le.POST,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/friends"),a.params={user_ids:i},a}return s(n)}(Oe),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)).users=a.users.map((function(t){return new Xa(e,t)})),s}return s(n)}(Ue),tc=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=le.DELETE,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/friends"),a.params={user_ids:i},a}return s(n)}(Oe),nc=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=le.GET,a.path="".concat(de,"/").concat(s,"/allow_friend_discovery"),a.params={},a}return s(n)}(Oe),rc=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)}(Ue),ac=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=le.PUT,a.path="".concat(de,"/").concat(s,"/allow_friend_discovery"),a.params={allow_friend_discovery:i},a}return s(n)}(Oe),sc=s((function e(t){r(this,e),this.key=t.key,this.url=t.url})),ic=s((function e(t){r(this,e),this.id=t.id,this.name=t.name,this.url=t.url,this.emojis=t.emojis?t.emojis.map((function(e){return new sc(e)})):[]})),oc=s((function e(t){r(this,e),this.emojiHash=t.emoji_hash||"",this.emojiCategories=t.emoji_categories?t.emoji_categories.map((function(e){return new ic(e)})):[]})),uc=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.call(this)).method=le.GET,e.path=Ee,e}return s(n)}(Oe),cc=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 oc(a),s}return s(n)}(Ue),lc=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=le.GET,a.path="".concat(Ee,"/").concat(s),a}return s(n)}(Oe),hc=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 ic(a),s}return s(n)}(Ue),dc=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=le.GET,a.path="".concat(ke,"/").concat(s),a}return s(n)}(Oe),fc=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 sc(a),s}return s(n)}(Ue),pc=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.call(this)).method=le.GET,e.path="".concat(Ce),e}return s(n)}(Oe),vc=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)}(Ue),_c=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=le.GET,a.path=de,a.params=ue({limit:s,token:i,user_ids:o,metadatakey:u,metadatavalues_in:c,nickname_startswith:l}),a}return s(n)}(Oe),mc=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 Xa(e,t)})),s.next=a.next,s}return s(n)}(Ue),gc=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 E(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=fs.of(this._iid),r=n.requestQueue,a=new _c(ce(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(mc),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}(Ii),yc=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=le.GET,a.path="".concat(de,"/").concat(s,"/block"),a.params=ue({limit:i,token:o,user_ids:u}),a}return s(n)}(Oe),kc=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 Xa(e,t)})),s.next=a.next,s}return s(n)}(Ue),Ec=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 E(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=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new yc(ce(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(kc),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}(Ii),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=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/friends"),a.params={limit:i,token:o},a}return s(n)}(Oe),wc=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 Xa(e,t)})),s.next=a.next,s}return s(n)}(Ue),Cc=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 E(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=fs.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(wc),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}(Ii),xc={},Sc=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"}(lu||(lu={}));var Tc,Ic=function(e){i(n,e);var t=f(n);function n(e){var a,s=e.code,i=void 0===s?lu.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:lu.STORE_NOT_DEFINED,message:"Store is not defined. Specify the store on NestDB()"})}},{key:"storeNotAvailable",get:function(){return new n({code:lu.STORE_NOT_AVAILABLE,message:"Store is not available. Check your environment settings."})}},{key:"storeNotAvailableInPrivateBrowsing",get:function(){return new n({code:lu.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:lu.STORE_IS_FULL,message:"Store is full."})}},{key:"storeNotInitialized",get:function(){return new n({code:lu.STORE_NOT_INITIALIZED,message:"Store is not initialized."})}},{key:"storeKeyTypeIsInvalid",get:function(){return new n({code:lu.STORE_INVALID_KEY_TYPE,message:"Store key should be string type."})}},{key:"storeBrokenIntegrity",get:function(){return new n({code:lu.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:lu.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:lu.STORE_ENCRYPTION_INVALID,message:"Encryption algorithm has changed. All the store should reset."})}},{key:"storeItemSizeExceeded",get:function(){return new n({code:lu.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:lu.STORE_READ_FAILED,message:"Failed to read from store."})}},{key:"storeWriteFailed",get:function(){return new n({code:lu.STORE_WRITE_FAILED,message:"Failed to write to store."})}},{key:"databaseSchemaNotOnUpgrade",get:function(){return new n({code:lu.DATABASE_SCHEMA_NOT_ON_UPGRADE,message:"Committing schema is not allowed when upgrade is not running."})}},{key:"collectionNotReady",get:function(){return new n({code:lu.COLLECTION_NOT_READY,message:"Collection is not ready due to an error during initialization."})}},{key:"collectionKeyNotMatch",get:function(){return new n({code:lu.COLLECTION_KEY_NOT_MATCH,message:"keyName of collection could not change."})}},{key:"collectionQueryNotValid",get:function(){return new n({code:lu.COLLECTION_QUERY_NOT_VALID,message:"Query parameter is not a valid format."})}},{key:"collectionInsertDuplicate",get:function(){return new n({code:lu.COLLECTION_INSERT_DUPLICATE,message:"The key already exists."})}},{key:"collectionKeyNotFound",get:function(){return new n({code:lu.COLLECTION_KEY_NOT_FOUND,message:"The key is not found."})}},{key:"collectionKeyNotGiven",get:function(){return new n({code:lu.COLLECTION_KEY_NOT_GIVEN,message:"The item should contain [keyName] property."})}},{key:"collectionWriteFailed",get:function(){return new n({code:lu.COLLECTION_WRITE_FAILED,message:"Failed to write an item."})}},{key:"collectionItemSizeExceeded",get:function(){return new n({code:lu.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:lu.INDEX_TABLE_IS_REQUIRED,message:"Index table is required."})}},{key:"indexTypesNotMatch",get:function(){return new n({code:lu.INDEX_TYPE_NOT_MATCH,message:"Indexed column should have primitive type."})}},{key:"compareTypesNotMatch",get:function(){return new n({code:lu.COMPARE_TYPE_NOT_MATCH,message:"Values to compare have different types."})}},{key:"circularReferenceFound",get:function(){return new n({code:lu.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 Nc,Mc=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 Ic.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},Ac=function(e,t){if(null==t)return 1;if(null==e)return-1;if(n(e)!==n(t))throw Ic.compareTypesNotMatch;var r=0;switch(n(e)){case"boolean":case"number":r=e-t;break;case"string":r=e.localeCompare(t)}return r},Oc=function(e,t){for(var n=0,r=0;r>>0)%t},Uc=function(e){return new Promise((function(t){setTimeout((function(){return t()}),e)}))},Rc=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(!(Ac(u,c)>0))return!1;break;case"/gte":case">=":var l=r[s],h=i[o];if(!(Ac(l,h)>=0))return!1;break;case"/lt":case"<":var d=r[s],f=i[o];if(!(Ac(d,f)<0))return!1;break;case"/lte":case"<=":var p=r[s],v=i[o];if(!(Ac(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 E=r[s];if(!(0,i[o])(E))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)},Lc=function(){},Dc=function(){return Promise.resolve()},Pc=function(e){return e},Fc=function(e,t){t()};!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Nc||(Nc={}));var Gc,qc,Hc,jc=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?Pc:u,l=t.backward,h=void 0===l?Dc:l,d=t.forward,f=void 0===d?Dc:d,p=t.complete,v=void 0===p?Lc: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 E(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 E(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}(),zc=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*Ac(this._indexer.origin[l].columnValues[s],this.condition[i][c])<=0){a=l;break}}else for(var h=a;h>=0;h--)if(o*Ac(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 E(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 Ic.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 E(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(Yc(e,t)).concat(n,".").concat(r)},Jc=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 E(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 E(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=Zc(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 E(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 E(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=Yc(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 E(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"}(Gc||(Gc={})),function(e){e.PENDING="pending",e.PERSISTENT="persistent",e.VOLATILE="volatile"}(qc||(qc={})),function(e){e[e.NO_CACHE=0]="NO_CACHE",e[e.DEFAULT=1]="DEFAULT",e[e.PERSISTENT=2]="PERSISTENT"}(Hc||(Hc={}));var Xc,$c=[qc.PENDING,qc.VOLATILE],el={},tl=function(){function e(t){var n=t.dbname,a=t.limit,s=void 0===a?256:a;return r(this,e),el[n]||(this.dbname=n,this._items=[],this._limit=s,el[n]=this),el[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]:Hc.DEFAULT;return E(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===Hc.PERSISTENT?qc.PERSISTENT:qc.VOLATILE},this.put(s)),t.next=9;break;case 8:r===Hc.PERSISTENT&&(s.state=qc.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]:Hc.DEFAULT,n=this._items.map((function(e){return e.key})).indexOf(e);if(n>-1){var r=this._items[n];return t===Hc.PERSISTENT&&(r.state=qc.PERSISTENT),t!==Hc.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)$c.includes(this._items[t].state)&&$c.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===qc.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===qc.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!==qc.VOLATILE}))}}],[{key:"get",value:function(e){return el[e]}}]),e}(),nl=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(Qc(e,t),"/trans.metadata")}(n,a),this.recordsetKey=function(e,t){return"".concat(Qc(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 E(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 E(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=tl.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=tl.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||Oc)(e,r)}(e,s,{hashFunction:this.hashFunction,base:this.metadata.blockHashBase,multiplier:this.metadata.blockHashMultiplier,constant:this.metadata.blockHashConstant})),"".concat(Wc(t,n)).concat(r,".").concat(a)}},{key:"_findBlock",value:function(e){return E(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=tl.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=rl.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 E(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 E(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=Sc.get(this.dbname),s=this.createBlockId(e),i=Math.floor(this._store.itemSizeLimit/a.itemSizeLimit),o=tl.get(this.dbname),t.next=6,o.find(this._store,s);case 6:if(u=t.sent,!(null==(c=u?rl.createFromCacheItem(u):new rl({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 E(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 E(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=Wc(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:tl.get(this.dbname).clearByCondition((function(e){return e.key.startsWith(n)}));case 11:case"end":return e.stop()}}),e,this)})))}}]),e}(),sl={},il=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(Qc(e,t),"/index.").concat(n)}(a,s,o.join(">"));return sl[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(Gc.COMMIT,this.indexerKey,(function(){return n.commit()})),this._transaction.on(Gc.ERROR,this.indexerKey,(function(){return n.abort()}))),sl[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 Ic.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=Ac(e[n],t[n]);if(0!==a)return r*a}return 0}},{key:"indexOf",value:function(e){if(this._table.length>0){for(var t=0,n=this._table.length-1;t<=n;){var r=Math.floor((t+n)/2),a=this.diff(e,this._table[r].columnValues);if(a>0)t=r+1;else{if(!(a<0))return[r,!0];n=r-1}}return[t,!1]}return[0,!1]}},{key:"ensure",value:function(){return E(this,void 0,void 0,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=tl.get(this.dbname),e.next=3,n.find(this._store,this.indexerKey,Hc.PERSISTENT);case 3:if(r=e.sent){e.next=33;break}return a=Wc(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,Hc.NO_CACHE);case 17:if(c=e.sent,l=rl.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=Mc(this._origin);case 35:sl[this.indexerKey]=this;case 36:case"end":return e.stop()}}),e,this,[[10,24,27,30]])})))}},{key:"drop",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return tl.get(this.dbname).remove(this.indexerKey),e.next=4,this._store.remove(this.indexerKey);case 4:delete sl[this.indexerKey];case 5:case"end":return e.stop()}}),e,this)})))}},{key:"addItem",value:function(e){return E(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 E(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 E(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=Mc(this._origin)}},{key:"abort",value:function(){this._table=Mc(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 sl)delete sl[e]}}]),e}(),ol=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 il.createKey(e)!==n.keyName})))),this._keyHash=o,this._store=c,this._mutex=new Vo(function(e,t){return"".concat(Qc(e,t),".lock")}(a,s)),this._blobContainer=new Jc({dbname:a,collectionName:s,store:c}),this._transaction=new nl({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 E(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=Sc.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 al({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 il.createKey(e)})),u=a?a.indexes.map((function(e){return il.createKey(e)})):[],c=y(u);try{for(c.s();!(l=c.n()).done;)h=l.value,o.includes(h)||i.push(il.parseKey(h))}catch(e){c.e(e)}finally{c.f()}return(d=[]).push.apply(d,_(s.map((function(e){var t=new il({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 il({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=Kc(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=il.createKey(e),r=y(this._indexers);try{for(r.s();!(t=r.n()).done;){var a=t.value;if(n===il.createKey(a.fields))return a}}catch(e){r.e(e)}finally{r.f()}throw Ic.indexTableIsRequired}},{key:"_upgradeBlockLevel",value:function(){return E(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=Kc(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 E(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 Ic.collectionInsertDuplicate;case 33:case"end":return t.stop()}}),n,this,[[14,24,27,30]])})))}},{key:"_requestUpsert",value:function(e){return E(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 E(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 E(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 E(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 E(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",Mc(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 Ic.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 Vc({condition:e.where,mutex:this._mutex,blockManager:this._blockManager,indexer:this._getIndexerBy(e.index),backward:!!e.backward});throw Ic.collectionNotReady}},{key:"insertOne",value:function(e){return E(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 Ic.collectionKeyNotGiven;case 6:return t.next=8,this._requestInsert(Mc(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 Ic.collectionNotReady;case 23:case"end":return t.stop()}}),n,this,[[3,14]])})))}},{key:"insertMany",value:function(e){return E(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 Ic.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(Mc(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 Ic.collectionNotReady;case 38:case"end":return t.stop()}}),n,this,[[3,29],[7,17,20,23]])})))}},{key:"upsertOne",value:function(e){return E(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 Ic.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpsert(Mc(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 Ic.collectionNotReady;case 23:case"end":return t.stop()}}),n,this,[[3,14]])})))}},{key:"upsertMany",value:function(e){return E(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 Ic.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(Mc(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 Ic.collectionNotReady;case 38:case"end":return t.stop()}}),n,this,[[3,29],[7,17,20,23]])})))}},{key:"update",value:function(e){return E(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 Ic.collectionKeyNotGiven;case 6:return t.next=8,this._requestUpdate(Mc(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 Ic.collectionNotReady;case 23:case"end":return t.stop()}}),n,this,[[3,14]])})))}},{key:"updateIf",value:function(e,n){return E(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 zc({condition:s,blockManager:this._blockManager,backward:c,indexer:this._getIndexerBy(o)}),r.next=9,h.each((function(e){return E(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,Rc(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 E(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 E(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 E(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 E(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 Ic.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 E(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 E(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 E(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 E(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}(),cl={},ll=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 cl[this.dbname]},set:function(e){cl[this.dbname]=e}},{key:"_getAllRawKeys",value:function(){return E(this,void 0,void 0,t().mark((function e(){return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!cl[this.dbname]){e.next=4;break}return e.abrupt("return",Object.keys(cl[this.dbname]));case 4:throw Ic.storeNotAvailable;case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRaw",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!cl[this.dbname]){t.next=6;break}return t.next=3,Uc(this.delay);case 3:return t.abrupt("return",cl[this.dbname][e]?Object.assign({key:e},cl[this.dbname][e]):null);case 6:throw Ic.storeNotAvailable;case 7:case"end":return t.stop()}}),n,this)})))}},{key:"_setRaw",value:function(e){return E(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(!cl[this.dbname]){t.next=7;break}return t.next=3,Uc(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,cl[this.dbname][i]=Object.freeze({data:o,metadata:u})}catch(e){r.e(e)}finally{r.f()}t.next=8;break;case 7:throw Ic.storeNotAvailable;case 8:case"end":return t.stop()}}),n,this)})))}},{key:"_removeRaw",value:function(e){return E(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(!cl[this.dbname]){t.next=7;break}return t.next=3,Uc(this.delay);case 3:r=y(e);try{for(r.s();!(a=r.n()).done;)s=a.value,cl[this.dbname][s]&&delete cl[this.dbname][s]}catch(e){r.e(e)}finally{r.f()}t.next=8;break;case 7:throw Ic.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 E(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 E(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,cl[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 E(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 E(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 E(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,Uc(this.delay);case 2:cl[this.dbname]={};case 3:case"end":return e.stop()}}),e,this)})))}}]),a}(ul),hl="NestDBStore";!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.OPENING=1]="OPENING",e[e.OPEN=2]="OPEN",e[e.CLOSED=3]="CLOSED"}(Xc||(Xc={}));var dl,fl=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=hl,e._state=Xc.UNINITIALIZED,e._openJobQueue=[],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:"state",get:function(){return this._state}},{key:"_openDatabase",value:function(e){var t=this;return new Promise((function(n,r){if(t._indexedDb){t._state=Xc.OPENING;var a=t._indexedDb.open(e);a.addEventListener("upgradeneeded",(function(e){e.target.result.createObjectStore(hl,{keyPath:"key"})})),a.addEventListener("success",(function(r){t._state=Xc.OPEN,t._database=r.target.result,t._openJobQueue.forEach((function(e){return e()})),t._openJobQueue=[],t._database.onclose=function(){t._database=void 0,t._state=Xc.OPENING,setTimeout((function(){t._openDatabase(e)}),5)},n(t._database)})),a.addEventListener("error",(function(e){t._state=Xc.UNINITIALIZED,r(e.target.error)}))}else r(Ic.storeNotAvailable)}))}},{key:"_getObjectStore",value:function(e){return E(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:if(!this._database){t.next=4;break}return t.abrupt("return",this._database.transaction(this._storeName,e).objectStore(this._storeName));case 4:t.t0=this._state,t.next=t.t0===Xc.UNINITIALIZED||t.t0===Xc.OPEN?7:t.t0===Xc.OPENING||t.t0===Xc.CLOSED?8:9;break;case 7:throw Ic.storeNotInitialized;case 8:return t.abrupt("return",new Promise((function(t){r._openJobQueue.push((function(){return t(r._getObjectStore(e))}))})));case 9:return t.next=11,this._getObjectStore(e);case 11:return t.abrupt("return",t.sent);case 12:case"end":return t.stop()}}),n,this)})))}},{key:"_getAllRawKeys",value:function(){return E(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._getObjectStore("readonly");case 2:return n=e.sent,e.next=5,new Promise((function(e,t){var r=n.getAllKeys();r.addEventListener("success",(function(t){e(t.target.result)})),r.addEventListener("error",(function(e){return t(e.target.error)}))}));case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"_getRaw",value:function(e){return E(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._getObjectStore("readonly");case 2:return r=t.sent,t.next=5,new Promise((function(t,n){var a=r.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 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"_setRaw",value:function(e){return E(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._getObjectStore("readwrite");case 2:return r=t.sent,t.next=5,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 5:case"end":return t.stop()}}),n,this)})))}},{key:"_removeRaw",value:function(e){return E(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._getObjectStore("readwrite");case 2:return r=t.sent,t.next=5,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 5:case"end":return t.stop()}}),n,this)})))}},{key:"_triggerDatabaseClose",value:function(){this._database&&this._database.onclose&&this._database.onclose(new Event("dummy"))}},{key:"checkAvailability",value:function(){return E(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||!qo()){e.next=13;break}if(!(qo()&&navigator.userAgent&&navigator.userAgent.includes("Edge/"))){e.next=9;break}if(this._window.indexedDB||!n.PointerEvent&&!n.MSPointerEvent){e.next=7;break}throw Ic.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(Ic.storeNotAvailableInPrivateBrowsing)},n.onsuccess=function(){return e()}}catch(e){t(Ic.storeNotAvailableInPrivateBrowsing)}else t(Ic.storeNotAvailable)}));case 11:e.next=14;break;case 13:case 16:throw Ic.storeNotAvailable;case 14:e.next=17;break;case 17:case"end":return e.stop()}}),e,this)})))}},{key:"init",value:function(e){return E(this,void 0,void 0,t().mark((function n(){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,this._openDatabase(e);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"clear",value:function(){return E(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._getObjectStore("readwrite");case 2:return n=e.sent,e.next=5,new Promise((function(e,t){var r=n.clear();r.addEventListener("success",(function(){return e()})),r.addEventListener("error",(function(e){return t(e.target.error)}))}));case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)})))}}]),a}(ul),pl=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 wl(e,t)}))),s}return s(n)}(Ue),Dl=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 E(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=fs.of(this._iid),r=n.requestQueue,a=new Rl(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Ll),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}(Li),Pl=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=le.GET,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/ban"),a.params=ue({limit:o,token:u}),a}return s(n)}(Oe),Fl=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).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 wl(e,t.user)}))),s}return s(n)}(Ue),Gl=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 E(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=fs.of(this._iid),r=n.requestQueue,a=new Pl(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Fl),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}(Li);e.ReportCategory=void 0,(El=e.ReportCategory||(e.ReportCategory={})).SPAM="spam",El.HARASSING="harassing",El.SUSPICIOUS="suspicious",El.INAPPROPRIATE="inappropriate";var ql,Hl,jl=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=le.POST,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/operators"),a.params={operator_ids:o},a}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.operatorUserIds;return(a=t.call(this)).method=le.DELETE,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/operators"),a.params={operator_ids:o},a}return s(n)}(Oe),Vl=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=le.GET,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/mute/").concat(o),a}return s(n)}(Oe),Bl=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=0,s.endAt=0;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)}(Ue),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.keys;return(a=t.call(this)).method=le.GET,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={keys:o,include_ts:!0},a}return s(n)}(Oe),Kl=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.metadata,o=a.ts;return s.metadata=i,s.ts=o,s}return s(n)}(Ue),Wl=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=le.POST,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={metadata:o,include_ts:!0},a}return s(n)}(Oe),Yl=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)}(Ue),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.metadata,u=e.upsert;return(a=t.call(this)).method=le.PUT,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={metadata:o,include_ts:!0,upsert:null!=u&&u},a}return s(n)}(Oe),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);var i=a.metadata,o=a.ts;return s.metadata=i,s.ts=o,s}return s(n)}(Ue),Xl=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),s.data&&(i.created=s.data.created,i.updated=s.data.updated,i.deleted=s.data.deleted),i}return s(n)}(qe),$l=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=le.DELETE,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/metadata/").concat(o),a.params={include_ts:!0},a}return s(n)}(Oe),eh=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.ts;return s.ts=i,s}return s(n)}(Ue),th=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=le.DELETE,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/metadata"),a.params={include_ts:!0},a}return s(n)}(Oe),nh=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.ts;return s.ts=i,s}return s(n)}(Ue),rh=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=le.GET,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={keys:o},a}return s(n)}(Oe),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)).metaCounter=a,s}return s(n)}(Ue),sh=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=le.POST,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={metacounter:o},a}return s(n)}(Oe),ih=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)}(Ue),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.metaCounter,u=e.upsert,c=void 0!==u&&u,l=e.mode,h=void 0===l?"set":l;return(a=t.call(this)).method=le.PUT,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={metacounter:o,upsert:c,mode:h},a}return s(n)}(Oe),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)).metaCounter=a,s}return s(n)}(Ue),ch=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),s.data&&(i.created=s.data.created,i.updated=s.data.updated,i.deleted=s.data.deleted),i}return s(n)}(qe),lh=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=le.DELETE,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/metacounter/").concat(o),a.params={},a}return s(n)}(Oe),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;return(a=t.call(this)).method=le.DELETE,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/metacounter"),a.params={},a}return s(n)}(Oe),dh=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=le.POST,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/mute"),a.params={user_id:o,seconds:u,description:c},a}return s(n)}(Oe),fh=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 wl(e,s.data),i}return s(n)}(qe),ph=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=le.DELETE,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/mute/").concat(encodeURIComponent(o)),a}return s(n)}(Oe),vh=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 wl(e,s.data),i}return s(n)}(qe),_h=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=le.POST,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/ban"),a.params=ue({user_id:o,seconds:u,description:c}),a}return s(n)}(Oe),mh=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 wl(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)}(qe),gh=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=le.DELETE,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/ban/").concat(encodeURIComponent(o)),a}return s(n)}(Oe),yh=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 wl(e,s.data),i}return s(n)}(qe),kh=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=le.PUT,a.path="".concat(Se(i),"/").concat(encodeURIComponent(s),"/freeze"),a.params={freeze:o},a}return s(n)}(Oe),Eh=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)}(qe),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.description;return(a=t.call(this)).method=le.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)}(Oe),wh=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=le.POST,s.path="".concat(ye,"/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)}(Oe),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.category,u=e.userId,c=e.offendingUserId,l=e.messageId,h=e.description;return(a=t.call(this)).method=le.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)}(Oe),xh=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(ce({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?t.parentMessageId:null,req_id:t.reqId,poll_id:t.pollId,pin_message:t.isPinnedMessage}))})}return s(a)}(oa),Sh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l;r(this,n),(i=t.call(this,e,"MESG",s)).message=new Hs(e,s);var h=fs.of(e).sdkState;return i.isMentioned=Ie(i.message.mentionType,null!==(c=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})))&&void 0!==c?c:[],h.userId),i.forceUpdateLastMessage=null!==(l=s.force_update_last_message)&&void 0!==l&&l,i}return s(n)}(qe),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:"MEDI",ackRequired:!0,payload:ue(ce({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:s,mentioned_message_template:t.mentionedMessageTemplate,apple_critical_alert_options:t.appleCriticalAlertOptions?xs.payloadify(t.appleCriticalAlertOptions):null,poll_id:t.pollId}))})}return s(a)}(oa),Ih=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l,h;r(this,n),(i=t.call(this,e,"MEDI",s)).message=new Hs(e,s);var d=fs.of(e).sdkState;return i.mentionCountChange=Ne({mentionType:null===(o=s.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=s.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},ce({mentionType:i.message.mentionType,mentionedUserIds:null!==(l=i.message.mentionedUserIds)&&void 0!==l?l:null===(h=i.message.mentionedUsers)||void 0===h?void 0:h.map((function(e){return e.userId}))}),d.userId),i}return s(n)}(qe),Nh=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(ce({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)}(oa),Mh=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l,h;r(this,n),(i=t.call(this,e,"FEDI",s)).message=new Qs(e,s);var d=fs.of(e).sdkState;return i.mentionCountChange=Ne({mentionType:null===(o=s.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=s.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},ce({mentionType:i.message.mentionType,mentionedUserIds:null!==(l=i.message.mentionedUserIds)&&void 0!==l?l:null===(h=i.message.mentionedUsers)||void 0===h?void 0:h.map((function(e){return e.userId}))}),d.userId),i}return s(n)}(qe),Ah=function(e){i(n,e);var t=f(n);function n(e){var a;return r(this,n),(a=t.call(this)).method=le.DELETE,a.path="".concat(Se(e.channelType),"/").concat(e.channelUrl,"/messages/").concat(e.messageId),a}return s(n)}(Oe),Oh=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)}(qe),Uh=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=le.POST,a.path="".concat(Se(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return s(n)}(Oe),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)).reactionEvent=new ks(a),s}return s(n)}(Ue),Lh=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=le.DELETE,a.path="".concat(Se(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/reactions"),a.params={reaction:u},a}return s(n)}(Oe),Dh=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 ks(Object.assign({},a)),s}return s(n)}(Ue),Ph=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=le.POST,a.path="".concat(Se(s),"/").concat(encodeURIComponent(i),"/messages/").concat(encodeURIComponent(o),"/translation"),a.params={target_langs:u},a}return s(n)}(Oe),Fh=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 Hs(e,a),s}return s(n)}(Ue),Gh=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=le.POST,s.path="".concat(Se(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),s.params=ue(ce({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:t.appleCriticalAlertOptions?xs.payloadify(t.appleCriticalAlertOptions):null,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption})),s}return s(a)}(Oe),qh=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 Hs(e,a),s}return s(n)}(Ue),Hh=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=le.POST,s.path="".concat(Se(u),"/").concat(encodeURIComponent(c),"/scheduled_messages"),s.params=ce({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 As.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:t.appleCriticalAlertOptions?xs.payloadify(t.appleCriticalAlertOptions):null,push_option:t.pushNotificationDeliveryOption}),s}return s(a)}(Oe),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)).message=new Qs(e,a),s}return s(n)}(Ue),zh=function(e){return L("string",e.title,!0)&&Fs(e.data)&&L("boolean",e.allowUserSuggestion,!0)&&L("boolean",e.allowMultipleVotes,!0)&&L("number",e.closeAt,!0)},Vh=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=le.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)}(Oe),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 qs(e,a),s}return s(n)}(Ue),Qh=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=le.DELETE,a.path="".concat(be,"/").concat(encodeURIComponent(s)),a}return s(n)}(Oe),Kh=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=le.PUT,a.path="".concat(be,"/").concat(encodeURIComponent(s),"/close"),a}return s(n)}(Oe),Wh=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 qs(e,a),s}return s(n)}(Ue),Yh=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=le.POST,a.path="".concat(be,"/").concat(encodeURIComponent(o),"/options"),a.params={channel_url:s,channel_type:i,text:u},a}return s(n)}(Oe),Zh=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 qs(e,a),s}return s(n)}(Ue),Jh=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=le.PUT,a.path="".concat(be,"/").concat(encodeURIComponent(s),"/options/").concat(encodeURIComponent(i)),a.params={text:o},a}return s(n)}(Oe),Xh=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 qs(e,a),s}return s(n)}(Ue),$h=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=le.DELETE,a.path="".concat(be,"/").concat(encodeURIComponent(s),"/options/").concat(encodeURIComponent(i)),a}return s(n)}(Oe),ed=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)}(oa),td=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=new ao(s),i.channelUrl=s.channel_url,i.channelType=s.channel_type,i}return s(n)}(qe),nd=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)).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 Xa(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 Ul(this._iid,this.url,this.channelType,e)}},{key:"createMutedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Dl(this._iid,this.url,this.channelType,e)}},{key:"createBannedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Gl(this._iid,this.url,this.channelType,e)}},{key:"createPreviousMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Di(this._iid,this.url,this.channelType,e)}},{key:"addOperators",value:function(e){return E(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 Za(F("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.requestQueue,s=new jl({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 E(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 Za(F("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.requestQueue,s=new zl({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 E(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=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Vl({channelUrl:this.url,channelType:this.channelType,userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Bl),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 E(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 Za(F("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.requestQueue,s=new Ql({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,a.send(s);case 5:return i=t.sent,o=i.as(Kl),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 E(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=fs.of(this._iid),r=n.requestQueue,a=new Ql({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(Kl),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 E(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=fs.of(this._iid),a=r.requestQueue,s=new Wl({channelUrl:this.url,channelType:this.channelType,metadata:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(Yl),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 E(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=fs.of(this._iid),s=a.requestQueue,i=new Zl({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(Jl),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 E(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 Za(L("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.requestQueue,s=new $l({channelUrl:this.url,channelType:this.channelType,key:e}),t.next=5,a.send(s);case 5:i=t.sent,o=i.as(eh),u=o.ts,this._removeFromCachedMetaData([e],u);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"deleteAllMetaData",value:function(){return E(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=fs.of(this._iid),r=n.requestQueue,a=new th({channelUrl:this.url,channelType:this.channelType}),e.next=4,r.send(a);case 4:s=e.sent,i=s.as(nh),o=i.ts,this._removeFromCachedMetaData(_(this._cachedMetaData.keys()),o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getMetaCounters",value:function(e){return E(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 Za(F("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.requestQueue,s=new rh({channelUrl:this.url,channelType:this.channelType,keys:e}),t.next=5,a.send(s);case 5:return i=t.sent,o=i.as(ah),u=o.metaCounter,t.abrupt("return",u);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getAllMetaCounters",value:function(){return E(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=fs.of(this._iid),r=n.requestQueue,a=new rh({channelUrl:this.url,channelType:this.channelType,keys:[]}),e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(ah),o=i.metaCounter,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"createMetaCounters",value:function(e){return E(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=fs.of(this._iid),a=r.requestQueue,s=new sh({channelUrl:this.url,channelType:this.channelType,metaCounter:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(ih),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 E(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=fs.of(this._iid),s=a.requestQueue,i=new oh({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(uh),c=u.metaCounter,t.abrupt("return",c);case 7:case"end":return t.stop()}}),r,this)})))}},{key:"increaseMetaCounters",value:function(e){return E(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=fs.of(this._iid),a=r.requestQueue,s=new oh({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(uh),u=o.metaCounter,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"decreaseMetaCounters",value:function(e){return E(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=fs.of(this._iid),a=r.requestQueue,s=new oh({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(uh),u=o.metaCounter,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"deleteMetaCounter",value:function(e){return E(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 Za(L("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.requestQueue,s=new lh({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 E(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=fs.of(this._iid),r=n.requestQueue,a=new hh({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 E(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 E(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 Za(L("string",e)&&L("number",n,!0)&&L("string",r,!0)).throw(A.invalidParameters),s=fs.of(this._iid),i=s.requestQueue,o=new dh({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 E(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 E(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 Za(L("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.requestQueue,s=new ph({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 E(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 E(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 Za(L("string",e)&&L("number",n,!0)&&L("string",r,!0)).throw(A.invalidParameters),s=fs.of(this._iid),i=s.requestQueue,o=new _h({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 E(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 E(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 Za(L("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.requestQueue,s=new gh({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 E(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=fs.of(this._iid),r=n.requestQueue,a=new kh({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 E(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=fs.of(this._iid),r=n.requestQueue,a=new kh({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 E(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({},ni),n),Za(L("number",e)&&ri(a)).throw(A.invalidParameters),s=wi.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 E(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({},ni),n),Za(L("number",e)&&ri(a)).throw(A.invalidParameters),s=wi.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 E(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({},ai),n),Za(L("number",e)&&si(a)).throw(A.invalidParameters),s=wi.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 E(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({},ai),n),Za(L("string",e)&&si(a)).throw(A.invalidParameters),s=wi.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=fs.of(this._iid).sessionManager;return ue(ce({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:s.currentUser?Ss.payloadify(s.currentUser):null,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 Xa.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 Hs(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 Qs(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 zs(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===b.REQUEST_CANCELED||n.code===b.FILE_UPLOAD_CANCEL_FAILED?t.sendingStatus=e.SendingStatus.CANCELED:r||(t.sendingStatus=e.SendingStatus.FAILED)}},{key:"sendUserMessage",value:function(e){var t=Object.assign(Object.assign({},No),e);return Za(Ao(t)).throw(A.invalidParameters),this._sendUserMessage(t)}},{key:"_sendUserMessage",value:function(n,r){var a=this,s=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=fs.of(this._iid),o=i.dispatcher,u=i.requestQueue;i.sessionManager;var c=null!=r?r:this._generateRequestId(),l=Date.now(),h=new Ci;return c||(c=this._generateRequestId()),Ea(2).then((function(){var r=a._createPendingUserMessage(n,c,l);o.dispatch(new ui({messages:[r],source:s?e.MessageEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING})),Ca((function(){return E(a,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",h._trigger(r));case 1:case"end":return e.stop()}}),e)})))}));var i=new xh(Object.assign(Object.assign({},n),{channelUrl:a.url,channelType:a.channelType,reqId:c}));u.send(i).then((function(n){var r=n.as(Sh).message;o.dispatch(new ui({messages:[r],source:e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS})),Ca((function(){return E(a,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",h._trigger(r));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(M(r))throw r;Ea(2).then((function(){var s=a._createPendingUserMessage(n,c,l),i=fs.of(a._iid).cacheContext.localCacheEnabled&&G(r.code);a._markMessageAsFailed(s,r,i),o.dispatch(new ui({messages:[s],source:s.sendingStatus===e.SendingStatus.PENDING?e.MessageEventSource.REQUEST_RESEND_MESSAGE:e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED})),Ca((function(){return E(a,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",h._triggerFailed(r,s));case 1:case"end":return e.stop()}}),e)})))}))}))}))})),h}},{key:"_autoResendUserMessage",value:function(e){return Za(e instanceof Hs&&!!e.messageParams).throw(A.invalidParameters),this._sendUserMessage(e.messageParams,e.reqId)}},{key:"resendUserMessage",value:function(e){var n;return E(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 Za(e instanceof Hs&&!e.scheduledInfo).throw(A.invalidParameters),a=new ca,s=null!==(n=e.messageParams)&&void 0!==n?n:Mo(e),this._sendUserMessage(s,e.reqId,!0).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 E(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({},Tl),n),Za(L("number",e)&&Il(a)).throw(A.invalidParameters),s=fs.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(Ih),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 E(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 Za(n instanceof u&&r instanceof Hs&&r.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===r.channelUrl&&!r.scheduledInfo).throw(A.invalidParameters),Za(!r.poll).throw(A.notSupportedError),c=new ca,l=null!==(a=r.messageParams)&&void 0!==a?a:ce(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 E(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 Za(e instanceof Hs&&e.messageId>0&&F("string",n)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.requestQueue,i=new Ph({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(Fh),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=fs.of(this._iid).requestQueue,s=Date.now(),i=this._generateRequestId();Ea(2).then((function(){var a=r._createPendingScheduledUserMessage(e,i,s);Ca((function(){return E(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));case 1:case"end":return e.stop()}}),e)})))}))}));var o=new Gh(Object.assign({reqId:i,channelType:this.channelType,channelUrl:this.url},e));a.send(o).then((function(e){var a=e.as(qh).message;Ca((function(){return E(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));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(a){if(M(a))throw a;Ea(2).then((function(){var o=r._createPendingScheduledUserMessage(e,i,s);r._markMessageAsFailed(o,a),Ca((function(){return E(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(o));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessage",value:function(e){var t=Object.assign(Object.assign({},Po),e);return Za(Go(t)).throw(A.invalidParameters),this._sendFileMessage(t)}},{key:"sendMultipleFilesMessage",value:function(e){var t,n=Object.assign(Object.assign({},Ko),e),r=fs.of(this._iid);Za(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 Wo(e)}))}(n,null===(t=r.appInfo)||void 0===t?void 0:t.multipleFilesMessageFileCountLimit)).throw(A.invalidParameters);var a=!!e.fileInfoList.find((function(e){var t=r.appInfo.uploadSizeLimit;return e.file instanceof Blob&&e.file.size>t||e.fileSize>t}));return Za(!a).throw(A.fileSizeLimitExceededError),this._sendMultipleFilesMessage(n)}},{key:"_sendFileMessage",value:function(n,r){var a=this,s=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=fs.of(this._iid),o=i.dispatcher;i.sessionManager;var u=wi.of(this._iid).fileMessageQueue,c=null!=r?r:this._generateRequestId(),l=Date.now(),h=new Ci;return c||(c=this._generateRequestId()),Ea(2).then((function(){var r=a._createPendingFileMessage(n,c,l);o.dispatch(new ui({messages:[r],source:s?e.MessageEventSource.LOCAL_MESSAGE_RESEND_STARTED:e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING})),Ca((function(){return E(a,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",h._trigger(r));case 1:case"end":return e.stop()}}),e)})))})),u.request(a,c,n).then((function(n){o.dispatch(new ui({messages:[n],source:e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS})),Ca((function(){return E(a,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",h._trigger(n));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(M(r))throw r;Ea(2).then((function(){var s=a._createPendingFileMessage(n,c,l),i=fs.of(a._iid).cacheContext.localCacheEnabled&&G(r.code);a._markMessageAsFailed(s,r,i),o.dispatch(new ui({messages:[s],source:s.sendingStatus===e.SendingStatus.PENDING?e.MessageEventSource.REQUEST_RESEND_MESSAGE:r.code===b.FILE_UPLOAD_CANCEL_FAILED?e.MessageEventSource.LOCAL_MESSAGE_CANCELED:e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED})),Ca((function(){return E(a,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",h._triggerFailed(r,s));case 1:case"end":return e.stop()}}),e)})))}))}))}))})),h}},{key:"_autoResendFileMessage",value:function(e){Za(e instanceof Qs&&!!e.messageParams).throw(A.invalidParameters);var t=fs.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,r){var a=this,s=fs.of(this._iid),i=s.dispatcher;s.sessionManager;var o=wi.of(this._iid).fileMessageQueue,u=null!=r?r:this._generateRequestId(),c=Date.now(),l=new Gi;return u||(u=this._generateRequestId()),Ea(2).then((function(){var r=a._createPendingMultipleFilesMessage(n,u,c);i.dispatch(new ui({messages:[r],source:e.MessageEventSource.EVENT_MESSAGE_SENT_PENDING})),Ca((function(){return E(a,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(r));case 1:case"end":return e.stop()}}),e)})))})),o.request(a,u,n,l).then((function(n){i.dispatch(new ui({messages:[n],source:e.MessageEventSource.EVENT_MESSAGE_SENT_SUCCESS})),Ca((function(){return E(a,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(n));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(r){if(M(r))throw r;Ea(2).then((function(){var s=a._createPendingMultipleFilesMessage(n,u,c);a._markMessageAsFailed(s,r),i.dispatch(new ui({messages:[s],source:e.MessageEventSource.EVENT_MESSAGE_SENT_FAILED})),Ca((function(){return E(a,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._triggerFailed(r,s));case 1:case"end":return e.stop()}}),e)})))}))}))}))})),l}},{key:"_createScheduledFileMessage",value:function(e,n,r,a){var s=this,i=fs.of(this._iid).requestQueue,o=new Hh(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(jh).message;Ca((function(){return E(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(r));case 1:case"end":return e.stop()}}),e)})))}))})).catch((function(i){if(M(i))throw i;Ea(2).then((function(){var o=s._createPendingScheduledFileMessage(e,r,a);s._markMessageAsFailed(o,i),Ca((function(){return E(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._triggerFailed(i,o));case 1:case"end":return e.stop()}}),e)})))}))}))}))}},{key:"sendFileMessages",value:function(e){Za(e.every((function(e){return Go(Object.assign(Object.assign({},Po),e))}))).throw(A.invalidParameters);var t,n=new Ci,r=y(e);try{for(r.s();!(t=r.n()).done;){var a=t.value;this.sendFileMessage(a).onPending((function(e){return n._trigger(e)})).onFailed((function(e,t){return n._triggerFailed(e,t)})).onSucceeded((function(e){return n._trigger(e)}))}}catch(e){r.e(e)}finally{r.f()}return n}},{key:"resendFileMessage",value:function(e,n){var r;return E(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),Za(e instanceof Qs&&s&&!e.scheduledInfo).throw(A.invalidParameters),i=new ca,o=Fo(e,n),this._sendFileMessage(o,e.reqId,!0).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 E(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({},Nl),n),Za(L("number",e)&&Ml(a)).throw(A.invalidParameters),s=fs.of(this._iid),i=s.requestQueue,o=new Nh(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(Mh),l=c.message,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"cancelUploadingFileMessage",value:function(e){return E(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 Za(L("string",e)).throw(A.invalidParameters),r=wi.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 E(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 Za(n instanceof u&&r instanceof Qs&&r.sendingStatus===e.SendingStatus.SUCCEEDED&&this.url===r.channelUrl&&!r.scheduledInfo).throw(A.invalidParameters),c=new ca,l=ce(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 E(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(Za(e instanceof Ns).throw(A.invalidParameters),!(e.messageId>0)){t.next=6;break}return r=fs.of(this._iid),a=r.requestQueue,s=new Ah({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 E(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 Za(e instanceof Ns&&e.messageId>0&&L("string",n)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.requestQueue,i=new Uh({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(Rh),c=u.reactionEvent,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"deleteReaction",value:function(e,n){return E(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 Za(e instanceof Ns&&e.messageId>0&&L("string",n)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.requestQueue,i=new Lh({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(Dh),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 E(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=fs.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(Ih),f=d.message,u.dispatch(new ui({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 E(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=fs.of(this._iid),u=o.dispatcher,c=o.requestQueue,l=new Nh({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(Mh),f=d.message,u.dispatch(new ui({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 E(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(Za(e instanceof Ns&&e.messageId>0&&F("string",n)).throw(A.invalidParameters),a=n.map((function(e){return new bs({key:e})})),!(e instanceof Qs)){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 E(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(Za(e instanceof Ns&&e.messageId>0&&F("string",n)).throw(A.invalidParameters),a=n.map((function(e){return new bs({key:e})})),!(e instanceof Qs)){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 E(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Za(e instanceof Ns&&e.messageId>0&&n.every((function(e){return e instanceof bs}))).throw(A.invalidParameters),!(e instanceof Qs)){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 E(this,void 0,void 0,t().mark((function r(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Za(e instanceof Ns&&e.messageId>0&&n.every((function(e){return e instanceof bs}))).throw(A.invalidParameters),!(e instanceof Qs)){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 E(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 Za(D(e.ReportCategory,n)&&L("string",r)).throw(A.invalidParameters),s=fs.of(this._iid),i=s.sdkState,o=s.requestQueue,u=new bh({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 E(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 Za(n instanceof Xa&&D(e.ReportCategory,r)&&L("string",a)).throw(A.invalidParameters),i=fs.of(this._iid),o=i.sdkState,u=i.requestQueue,c=new wh({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 E(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 Za(n instanceof Ms&&D(e.ReportCategory,r)&&L("string",a)).throw(A.invalidParameters),i=fs.of(this._iid),o=i.sdkState,u=i.requestQueue,c=new Ch({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 E(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 Za(L("number",e)&&zh(n)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.requestQueue,i=new Vh(Object.assign({pollId:e},n)),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Bh),c=u.poll,t.abrupt("return",c);case 8:case"end":return t.stop()}}),r,this)})))}},{key:"deletePoll",value:function(e){return E(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),Za(r).throw(A.invalidParameters),a=fs.of(this._iid),s=a.requestQueue,i=new Qh({pollId:e}),t.next=6,s.send(i);case 6:case"end":return t.stop()}}),n,this)})))}},{key:"closePoll",value:function(e){return E(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),Za(r).throw(A.invalidParameters),a=fs.of(this._iid),s=a.requestQueue,i=new Kh({pollId:e}),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(Wh),c=u.poll,t.abrupt("return",c);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"addPollOption",value:function(e,n){return E(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(),Za(a).throw(A.invalidParameters),s=fs.of(this._iid),i=s.requestQueue,o=new Yh({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(Zh),l=c.poll,t.abrupt("return",l);case 9:case"end":return t.stop()}}),r,this)})))}},{key:"updatePollOption",value:function(e,n,r){return E(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(),Za(s).throw(A.invalidParameters),i=fs.of(this._iid),o=i.requestQueue,u=new Jh({pollId:e,pollOptionId:n,optionText:r}),t.next=6,o.send(u);case 6:return c=t.sent,l=c.as(Xh),h=l.poll,t.abrupt("return",h);case 9:case"end":return t.stop()}}),a,this)})))}},{key:"deletePollOption",value:function(e,n){return E(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),Za(a).throw(A.invalidParameters),s=fs.of(this._iid),i=s.requestQueue,o=new $h({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 E(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),Za(s).throw(A.invalidParameters),i=fs.of(this._iid),o=i.requestQueue,u=i.dispatcher,c=new ed({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(td),d=h.event,u.dispatch(new fi({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 E(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 Za(L("number",e)).throw(A.invalidParameters),r=no.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 E(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 Za(L("string",e,!0)),r=no.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 oo(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 lo(this._iid,{channelUrl:this.url,channelType:this.channelType,pollId:e,pollOptionId:t,limit:n})}}],[{key:"payloadify",value:function(e){return ue(ce(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:e.creator?Xa.payloadify(e.creator):null,created_at:e.createdAt/1e3})))}}]),u}(Ha),rd=function(){function n(e,a,s){var i=this;r(this,n),this._storeInitialized=!1,this._iid=e,this.options=a;var o=fs.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 ru({logger:f,connectionDelegate:{reconnect:function(){var t=fs.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(){fs.of(e).connectionManager.disconnect()}}});var _=new iu(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 nu({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 da){if(n.stateType===sa.CONNECTED)_.processNonAutoResendRegisteredPendingMessages()}else if(n instanceof qe){if("USEV"===n.code){var r=n.as(vu).event;if(r.category===jo.FRIEND_DISCOVERED){var a=uu.getDataAsFriendDiscoveredEvent(e,r).friendDiscoveries;Ca((function(){return E(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&&e.onFriendsDiscovered(a)})));case 1:case"end":return e.stop()}}),e)})))}))}}}else if(n instanceof ua){var s=fs.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&&Ca((function(){return E(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&&e.onTotalUnreadMessageCountUpdated(s.all,s.customTypes)})));case 1:case"end":return e.stop()}}),e)})))}))}else n instanceof $a?c.preference.set(i._getUserProfileCacheKey(u.userId),es.payloadify(n.userProfile)):n instanceof Le&&n.error&&n.error.isSessionRevokedError&&(f.debug("session revoked."),i.disconnect())}))}return s(n,[{key:"appId",get:function(){return fs.of(this._iid).sdkState.appId}},{key:"appInfo",get:function(){var e=fs.of(this._iid).appInfo;return null!=e?e:null}},{key:"appVersion",get:function(){var e;return null!==(e=fs.of(this._iid).sdkState.appVersion)&&void 0!==e?e:""}},{key:"debugMode",get:function(){return!!fs.of(this._iid).debugMode}},{key:"logLevel",get:function(){return fs.of(this._iid).logger.level},set:function(e){fs.of(this._iid).logger.level=e}},{key:"isCacheEnabled",get:function(){return fs.of(this._iid).cacheContext.localCacheEnabled}},{key:"localCacheConfig",get:function(){var e=fs.of(this._iid).cacheContext;return e.localCacheEnabled?e.localCacheConfig:null}},{key:"ekey",get:function(){return fs.of(this._iid).sessionManager.ekey}},{key:"currentUser",get:function(){var e;return null!==(e=fs.of(this._iid).sessionManager.currentUser)&&void 0!==e?e:null}},{key:"connectionState",get:function(){var t=fs.of(this._iid).connectionManager;return t.isConnected?e.ConnectionState.OPEN:t.isConnecting?e.ConnectionState.CONNECTING:e.ConnectionState.CLOSED}},{key:"lastConnectedAt",get:function(){var e=fs.of(this._iid),t=e.connectedAt;return e.connectionManager.isConnected?t:0}},{key:"fcmPushToken",get:function(){var e;return null!==(e=this._fcmPushToken)&&void 0!==e?e:null}},{key:"apnsPushToken",get:function(){var e;return null!==(e=this._apnsPushToken)&&void 0!==e?e:null}},{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=fs.of(this._iid),t=e.debugMode,n=e.cacheContext;if(t)return n.store instanceof ll?n.store:null;throw A.debugModeRequired}},{key:"addExtension",value:function(e,t){var n=fs.of(this._iid).sdkState;["sb_uikit","sb_syncmanager","device-os-platform"].indexOf(e)>-1&&n.extensions&&(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 E(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=fs.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.replaceStore(new ll),t.next=12,this._safeInitializeStore(e);case 12:case"end":return t.stop()}}),n,this,[[1,7]])})))}},{key:"initializeCache",value:function(e){return E(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=fs.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!==dl.CLOSED&&s.nestdb.name===c){t.next=15;break}return(l=s.nestdb=new kl({name:"sendbird@".concat(a.appId,"/").concat(e,".db"),version:2,store:s.store})).on("upgrade",Xo(l,s.store)),l.on("storeReplaced",(function(e){s.replaceStore(e),s.localCacheEnabled=!1,l.on("upgrade",Xo(l,s.store))})),t.next=13,l.open();case 13:this._storeInitialized=!0,o.dispatch(new cu(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 E(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=fs.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 E(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=fs.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 E(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(Za(F("string",e)).throw(A.invalidParameters),r=eu.of(this._iid),a=Jo.of(this._iid),!r||!a){n.next=6;break}return n.next=6,Promise.all(e.map((function(e){return E(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,n){return E(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 Za(L("string",e)&&L("string",n,!0)).throw(A.invalidParameters),a=fs.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=fs.of(this._iid),c.dispatcher.dispatch(new pu),t.next=14;break;case 9:t.prev=9,t.t0=t.catch(2),l=fs.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 es(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=fs.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 E(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=fs.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 E(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=fs.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=fs.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=fs.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){Za(e instanceof vo).throw(A.invalidParameters),fs.of(this._iid).sessionManager.handler=e}},{key:"addUserEventHandler",value:function(e,t){Za(L("string",e)&&t instanceof mo).throw(A.invalidParameters),fs.of(this._iid).userEventHandlers.set(e,t)}},{key:"removeUserEventHandler",value:function(e){fs.of(this._iid).userEventHandlers.delete(e)}},{key:"removeAllUserEventHandler",value:function(){fs.of(this._iid).userEventHandlers.clear()}},{key:"addConnectionHandler",value:function(e,t){Za(L("string",e)&&t instanceof _o).throw(A.invalidParameters),fs.of(this._iid).connectionHandlers.set(e,t)}},{key:"removeConnectionHandler",value:function(e){fs.of(this._iid).connectionHandlers.delete(e)}},{key:"removeAllConnectionHandler",value:function(){fs.of(this._iid).connectionHandlers.clear()}},{key:"createApplicationUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new gc(this._iid,e)}},{key:"createBlockedUserListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Ec(this._iid,e)}},{key:"createFriendListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Cc(this._iid,e)}},{key:"createMessageSearchQuery",value:function(e){return new Ri(this._iid,e)}},{key:"createPollListQuery",value:function(e){return new oo(this._iid,Object.assign({},e))}},{key:"createPollVoterListQuery",value:function(e){return new lo(this._iid,Object.assign({},e))}},{key:"buildUserFromSerializedData",value:function(e){var t=Ya(e);return new Xa(this._iid,Xa.payloadify(t))}},{key:"updateCurrentUserInfo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return E(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({},fo),e),Za(po(r)).throw(A.invalidParameters),!this.currentUser){t.next=13;break}return a=fs.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new _u(Object.assign({userId:s.userId},r)),t.next=7,i.send(o);case 7:return u=t.sent,c=u.as(mu),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 E(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(Za(F("string",e)).throw(A.invalidParameters),!this.currentUser){t.next=12;break}return r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new _u({userId:a.userId,preferredLanguages:e}),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(mu),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 E(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(Za(L("string",n)).throw(A.invalidParameters),!this.currentUser){r.next=20;break}if(r.prev=2,a=fs.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 yu({userId:i.userId,token:n}),r.next=9,o.send(u);case 9:return r.next=11,xa((function(){return E(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 E(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(Za(L("string",n)).throw(A.invalidParameters),!this.currentUser){r.next=20;break}return r.prev=2,a=fs.of(this._iid),s=a.sessionManager,i=a.sdkState,o=a.requestQueue,u=new Eu({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 E(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 E(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=fs.of(this._iid),a=r.sessionManager,s=r.sdkState,i=r.requestQueue,o=new wu({userId:s.userId}),n.next=5,i.send(o);case 5:return u=n.sent,c=u.lastDeletedAt,n.next=9,xa((function(){return E(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 E(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(Za(L("string",n)).throw(A.invalidParameters),!this.currentUser){r.next=20;break}if(r.prev=2,a=fs.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 gu({userId:i.userId,token:n}),r.next=9,o.send(u);case 9:return r.next=11,xa((function(){return E(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 E(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(Za(L("string",n)).throw(A.invalidParameters),!this.currentUser){r.next=20;break}return r.prev=2,a=fs.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 E(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 E(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=fs.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 E(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 E(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=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Su({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 E(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 Za(L("boolean",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Iu({userId:a.userId,willAutoAccept:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Nu),c=u.autoAccept,t.abrupt("return",{autoAccept:c});case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getDoNotDisturb",value:function(){return E(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=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Mu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Au),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 E(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 Za(L("boolean",e)&&L("number",n)&&L("number",r)&&L("number",a)&&L("number",s)&&L("string",i)).throw(A.invalidParameters),u=fs.of(this._iid),c=u.sdkState,l=u.requestQueue,h=new Ou({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(Uu),p=f.preference,t.abrupt("return",p);case 8:case"end":return t.stop()}}),o,this)})))}},{key:"getSnoozePeriod",value:function(){return E(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=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Ru({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Lu),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 E(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 Za(L("boolean",e)&&L("number",n)&&L("number",r)).throw(A.invalidParameters),s=fs.of(this._iid),i=s.sdkState,o=s.requestQueue,u=new Du({userId:i.userId,snoozeOn:e,startTs:n,endTs:r}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(Pu),h=l.snoozePeriod,t.abrupt("return",h);case 8:case"end":return t.stop()}}),a,this)})))}},{key:"getMyPushTokensByToken",value:function(n,r){return E(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 Za(L("string",n)&&D(e.PushTokenType,r)).throw(A.invalidParameters),s=fs.of(this._iid),i=s.sdkState,o=s.requestQueue,u=s.sessionManager,c=new Cu({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 E(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=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new qu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,e.abrupt("return",i.as(Hu).pushTriggerOption);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTriggerOption",value:function(n){return E(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 Za(D(e.PushTriggerOption,n)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new ju({userId:s.userId,pushTriggerOption:n}),t.next=5,i.send(o);case 5:return u=t.sent,t.abrupt("return",u.as(zu).pushTriggerOption);case 7:case"end":return t.stop()}}),r,this)})))}},{key:"getPushTemplate",value:function(){return E(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=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Vu({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,e.abrupt("return",i.as(Bu).name);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"setPushTemplate",value:function(n){return E(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 Za(D(e.PushTemplate,n)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Qu({userId:s.userId,templateName:n}),t.next=5,i.send(o);case 5:return u=t.sent,t.abrupt("return",u.as(Ku).name);case 7:case"end":return t.stop()}}),r,this)})))}},{key:"blockUser",value:function(e){return E(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 Za(e instanceof Xa||L("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Fu({userId:a.userId,blockedUserId:e instanceof Xa?e.userId:e}),t.next=5,s.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"blockUserWithUserId",value:function(e){return E(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 E(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 Za(e instanceof Xa||L("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Gu({userId:a.userId,unblockedUserId:e instanceof Xa?e.userId:e}),t.next=5,s.send(i);case 5:case"end":return t.stop()}}),n,this)})))}},{key:"unblockUserWithUserId",value:function(e){return E(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 E(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 Za(L("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Wu({userId:a.userId,token:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(Yu),c=u.changelogs,t.abrupt("return",c);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getAllowFriendDiscovery",value:function(){return E(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=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new nc({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(rc),u=o.allowFriendDiscovery,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setAllowFriendDiscovery",value:function(e){return E(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 Za(L("boolean",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new ac({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 E(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=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Zu({userId:a.userId,discoveries:e}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(Ju),c=u.friendDiscoveryRequestId,t.abrupt("return",c);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriendDiscovery",value:function(e){return E(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 E(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 Za(F("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new Xu({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 E(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 Za(F("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new $u({userId:a.userId,userIds:e}),t.next=5,s.send(i);case 5:return o=t.sent,u=o.as(ec),c=u.users,t.abrupt("return",c);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"deleteFriend",value:function(e){return E(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 E(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 Za(F("string",e)).throw(A.invalidParameters),r=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new tc({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 E(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=fs.of(this._iid),r=n.requestQueue,a=new uc,e.next=4,r.send(a);case 4:return s=e.sent,i=s.as(cc),o=i.emojiContainer,e.abrupt("return",o);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getEmojiCategory",value:function(e){return E(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=fs.of(this._iid),a=r.requestQueue,s=new lc({categoryId:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(hc),u=o.emojiCategory,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"getEmoji",value:function(e){return E(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=fs.of(this._iid),a=r.requestQueue,s=new dc({key:e}),t.next=4,a.send(s);case 4:return i=t.sent,o=i.as(fc),u=o.emoji,t.abrupt("return",u);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"getUIKitConfiguration",value:function(){return E(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=fs.of(this._iid),Za(n.hasExtension("sb_uikit")).throw(A.notSupportedError),r=n.requestQueue,a=new pc,e.next=6,r.send(a);case 6:return s=e.sent,i=s.as(vc),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=e.modules,s=void 0===a?[]:a,i=e.options,o=void 0===i?new H:i,u=e.debugMode,c=void 0!==u&&u,l=e.customApiHost,h=e.customWebSocketHost,d=e.newInstance,f=void 0!==d&&d,p=e.logLevel,v=e.localCacheEnabled,m=void 0!==v&&v,g=e.localCacheConfig,y=void 0===g?new te:g,k=e.localCacheEncryption,E=e.useAsyncStorageStore,b=void 0===E?null:E,w=e.appStateToggleEnabled,C=void 0===w||w;if(!ql||f){var x="su-".concat(re()),S=null!=k?k:{encrypt:function(e){return e},decrypt:function(e){return e}},T=new ll({encryption:S});c||(T=Fe()?b?new pl({AsyncStorage:b,encryption:S}):new ll({encryption:S}):new fl({encryption:S})),new fs(x,{appId:t,appVersion:r,options:o,apiHost:null!=l?l:"https://api-".concat(t,".sendbird.com"),websocketHost:null!=h?h:"wss://ws-".concat(t,".sendbird.com"),store:T,encryption:S,logLevel:p,localCacheEnabled:m,localCacheConfig:y,debugMode:c,appStateToggleEnabled:C});var I=[new qi,new ho],N=new n(x,o,[].concat(_(s),I));return ql||(ql=N),N}return ql}},{key:"instance",get:function(){return ql}},{key:"version",get:function(){return w}}]),n}();e.MemberState=void 0,(Hl=e.MemberState||(e.MemberState={})).NONE="none",Hl.JOINED="joined",Hl.INVITED="invited",Hl.LEFT="left";var ad,sd,id,od,ud,cd,ld,hd,dd=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,"boolean"==typeof s.is_muted&&(i.isMuted=s.is_muted),"boolean"==typeof s.is_blocked_by_me&&(i.isBlockedByMe=s.is_blocked_by_me),"boolean"==typeof s.is_blocking_me&&(i.isBlockingMe=s.is_blocking_me),i}return s(a,null,[{key:"payloadify",value:function(e){return ue(ce(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})))}}]),a}(wl),fd=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 Xa(i._iid,s.user),i.readAt=s.ts,i}return s(a)}(Ha);e.PublicChannelFilter=void 0,(ad=e.PublicChannelFilter||(e.PublicChannelFilter={})).ALL="all",ad.PUBLIC="public",ad.PRIVATE="private",e.MyMemberStateFilter=void 0,(sd=e.MyMemberStateFilter||(e.MyMemberStateFilter={})).ALL="all",sd.JOINED="joined_only",sd.INVITED="invited_only",sd.INVITED_BY_FRIEND="invited_by_friend",sd.INVITED_BY_NON_FRIEND="invited_by_non_friend",e.SuperChannelFilter=void 0,(id=e.SuperChannelFilter||(e.SuperChannelFilter={})).ALL="all",id.SUPER="super",id.NON_SUPER="nonsuper",id.BROADCAST_ONLY="broadcast_only",id.EXCLUSIVE_ONLY="exclusive_only",e.UnreadChannelFilter=void 0,(od=e.UnreadChannelFilter||(e.UnreadChannelFilter={})).ALL="all",od.UNREAD_MESSAGE="unread_message",e.HiddenChannelFilter=void 0,(ud=e.HiddenChannelFilter||(e.HiddenChannelFilter={})).ALL="all",ud.UNHIDDEN="unhidden_only",ud.HIDDEN="hidden_only",ud.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",ud.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide",e.OperatorFilter=void 0,(cd=e.OperatorFilter||(e.OperatorFilter={})).ALL="all",cd.OPERATOR="operator",cd.NONOPERATOR="nonoperator",e.QueryType=void 0,(ld=e.QueryType||(e.QueryType={})).AND="AND",ld.OR="OR",e.GroupChannelSearchField=void 0,(hd=e.GroupChannelSearchField||(e.GroupChannelSearchField={})).MEMBER_NICKNAME="member_nickname",hd.CHANNEL_NAME="channel_name";var pd,vd=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||!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,n=new t;this.searchFilter&&n.setSearchFilter(this.searchFilter.fields,null!==(e=this.searchFilter.query)&&void 0!==e?e:void 0),this.userIdsFilter&&n.setUserIdsFilter(this.userIdsFilter.userIds,this.userIdsFilter.includeMode,this.userIdsFilter.queryType);var r=JSON.parse(JSON.stringify(this));return Object.keys(r).forEach((function(e){n[e]=r[e]})),n}},{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}(),_d=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 Za(!!e).throw(A.databaseError),e.collection(go)}},{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 Ff.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(d&&d===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 E(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 E(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 E(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:(null==(u=t.sent)?void 0:u._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}(Ha);!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"}(pd||(pd={}));var md,gd=function(){function t(e){var n;r(this,t),this.channelUrl=e.channel_url,this.channelType=e.channel_type,this.category=e.cat,this.data=null!==(n=e.data)&&void 0!==n?n:{},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}(),yd={invitedUserIds:void 0,channelUrl:void 0,coverUrl:void 0,coverImage:void 0,isDistinct:void 0,isSuper:void 0,isBroadcast:void 0,isExclusive:void 0,isPublic:void 0,isDiscoverable:void 0,isStrict:void 0,isEphemeral:void 0,accessCode:void 0,name:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,messageSurvivalSeconds:void 0},kd=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,!0))&&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)},Ed={customTypes:void 0,includeEmpty:!1,includeFrozen:!0},bd=function(e){return F("string",e.customTypes,!0)&&L("boolean",e.includeEmpty)&&L("boolean",e.includeFrozen)},wd={myMemberStateFilter:e.MyMemberStateFilter.ALL},Cd=function(t){return D(e.MyMemberStateFilter,t.myMemberStateFilter)};e.UnreadItemKey=void 0,(md=e.UnreadItemKey||(e.UnreadItemKey={})).GROUP_CHANNEL_UNREAD_MENTION_COUNT="group_channel_unread_mention_count",md.NONSUPER_UNREAD_MENTION_COUNT="non_super_group_channel_unread_mention_count",md.SUPER_UNREAD_MENTION_COUNT="super_group_channel_unread_mention_count",md.GROUP_CHANNEL_UNREAD_MESSAGE_COUNT="group_channel_unread_message_count",md.NONSUPER_UNREAD_MESSAGE_COUNT="non_super_group_channel_unread_message_count",md.SUPER_UNREAD_MESSAGE_COUNT="super_group_channel_unread_message_count",md.GROUP_CHANNEL_INVITATION_COUNT="group_channel_invitation_count",md.NONSUPER_INVITATION_COUNT="non_super_group_channel_invitation_count",md.SUPER_INVITATION_COUNT="super_group_channel_invitation_count";var xd,Sd={keys:[]},Td=function(t){return F(e.UnreadItemKey,t.keys)},Id={channelCustomTypesFilter:void 0,superChannelFilter:e.SuperChannelFilter.ALL},Nd=function(t){return F("string",t.channelCustomTypesFilter,!0)&&D(e.SuperChannelFilter,t.superChannelFilter)},Md={channelUrl:void 0,scheduledStatus:void 0,messageTypeFilter:e.MessageTypeFilter.ALL},Ad=function(t){return L("string",t.channelUrl,!0)&&F(e.ScheduledStatus,t.scheduledStatus,!0)&&D(e.MessageTypeFilter,t.messageTypeFilter)},Od=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 E(a,void 0,void 0,t().mark((function n(){var r,a,u,c,l,h,d,f,p,v,_,m,g,k=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e instanceof du)){n.next=27;break}r=e.channels,a=e.source,u=e.isWebSocketEventComing,c=e.data,l=r.filter((function(e){return e instanceof Kp})),h=s.filterOffsetChanged(l),d=y(h),n.prev=5,d.s();case 7:if((f=d.n()).done){n.next=13;break}return p=f.value,n.next=11,i.removeUnderOffset(p.url,p.messageOffsetTimestamp);case 11:n.next=7;break;case 13:n.next=18;break;case 15:n.prev=15,n.t0=n.catch(5),d.e(n.t0);case 18:return n.prev=18,d.f(),n.finish(18);case 21:return n.next=23,s.upsert(l);case 23:v=n.sent,u||this._broadcastUpdateEvent(v,a,c),n.next=39;break;case 27:if(!(e instanceof fu)){n.next=36;break}return _=e.channelUrls,m=e.source,g=e.isWebSocketEventComing,n.next=31,s.remove(_);case 31:return n.next=33,xa((function(){return E(k,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(_),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:g||this._broadcastRemoveEvent(_,m),n.next=39;break;case 36:if(!(e instanceof cu)){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;){var s=r.value;s.onUpdate&&s.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;){var a=n.value;a.onRemove&&a.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}(),Ud=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._observers=new Map,this._cacheContext=s,this._logger=c,u.on((function(e){return E(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,b,w,C,x,S=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(e instanceof ui)){n.next=14;break}if(r=e.messages,a=e.source,s=e.isWebSocketEventComing,u=r.filter((function(e){return e.messageId>0})),c=r.filter((function(e){return 0===e.messageId})),!(u.length>0)){n.next=8;break}return n.next=7,xa((function(){return E(S,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(u);case 2:return e.next=4,o.remove(u.map((function(e){return e instanceof Ms?e.reqId:null})).filter((function(e){return null!==e})));case 4:case"end":return e.stop()}}),e)})))}));case 7:s||this._broadcastUpdateEvent(u,a);case 8:if(!(c.length>0)){n.next=12;break}return n.next=11,xa((function(){return E(S,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(c);case 2:case"end":return e.stop()}}),e)})))}));case 11:s||this._broadcastUpdateEvent(c,a);case 12:n.next=61;break;case 14:if(!(e instanceof ci)){n.next=21;break}return l=e.messageIds,h=e.source,d=e.isWebSocketEventComing,n.next=18,xa((function(){return E(S,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(l);case 2:case"end":return e.stop()}}),e)})))}));case 18:d||this._broadcastRemoveEvent(l,h),n.next=61;break;case 21:if(!(e instanceof li)){n.next=28;break}return f=e.reqId,p=e.source,n.next=25,xa((function(){return E(S,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([f]);case 2:case"end":return e.stop()}}),e)})))}));case 25:this._broadcastRemoveUnsentEvent(f,p),n.next=61;break;case 28:if(!(e instanceof hi)){n.next=41;break}if(v=e.polls,_=e.source,!this._cacheContext.localCacheEnabled){n.next=38;break}return m=v.map((function(e){return e.messageId})),n.next=34,Promise.all(m.map((function(e){return i.get(e)})));case 34:return g=n.sent.filter((function(e){return e})),g.length>0&&v.forEach((function(e){var t=g.find((function(t){return t.messageId===e.messageId}));t&&t.applyPoll(e)})),n.next=38,xa((function(){return E(S,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(g);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}));case 38:this._broadcastPollChangeLogEvent(v,_),n.next=61;break;case 41:if(!(e instanceof di)){n.next=52;break}return y=e.event,k=e.source,n.next=45,i.get(y.messageId);case 45:if(!((b=n.sent)&&b.isUserMessage()&&b.poll&&b.poll.applyPollUpdateEvent(y))){n.next=49;break}return n.next=49,xa((function(){return E(S,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([b]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}));case 49:this._broadcastPollUpdateEvent(y,k),n.next=61;break;case 52:if(!(e instanceof fi)){n.next=61;break}return w=e.event,C=e.source,n.next=56,i.get(w.messageId);case 56:if(!((x=n.sent)&&x.isUserMessage()&&x.poll&&x.poll.applyPollVoteEvent(w))){n.next=60;break}return n.next=60,xa((function(){return E(S,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([x]);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}));case 60:this._broadcastPollVoteEvent(w,C);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;){var a=n.value;a.onUpdate&&a.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;){var a=n.value;a.onPollChangeLogUpdate&&a.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;){var a=n.value;a.onPollUpdate&&a.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;){var a=n.value;a.onPollVote&&a.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;){var a=n.value;a.onRemove&&a.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;){var a=n.value;a.onRemoveUnsent&&a.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}(),Rd=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({},Ed),u),l=c.customTypes,h=c.includeEmpty,d=c.includeFrozen;return a.method=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/my_group_channels/changelogs"),a.params=ue(ce({show_delivery_receipt:!0,show_member:!0,show_read_receipt:!0,change_ts:i||null,token:o,custom_types:l,show_empty:h,show_frozen:d})),a}return s(n)}(Oe),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)).updatedChannels=a.updated.map((function(t){return new Kp(e,t)})),s.deletedChannelUrls=a.deleted,s.hasMore=a.has_more,s.token=a.next,s}return s(n)}(Ue),Dd=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=le.GET,a.path="".concat(i?ve:pe,"/").concat(encodeURIComponent(s)),a.params={show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0},a}return s(n)}(Oe),Pd=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 Kp(e,a),s}return s(n)}(Ue),Fd={includeEmpty:!1,includeFrozen:!0,includeMetaData:!0,channelUrlsFilter:void 0,customTypesFilter:void 0,customTypeStartsWithFilter:void 0,nicknameContainsFilter:void 0,nicknameStartsWithFilter:void 0,nicknameExactMatchFilter:void 0,channelNameContainsFilter:void 0,myMemberStateFilter:e.MyMemberStateFilter.ALL,unreadChannelFilter:e.UnreadChannelFilter.ALL,superChannelFilter:e.SuperChannelFilter.ALL,publicChannelFilter:e.PublicChannelFilter.ALL,hiddenChannelFilter:e.HiddenChannelFilter.ALL,userIdsFilter:{userIds:[],includeMode:!0,queryType:e.QueryType.AND},searchFilter:{query:void 0,fields:[]},metadataKey:void 0,metadataValues:void 0,metadataOrderKeyFilter:void 0,metadataValueStartsWith:void 0,order:e.GroupChannelListOrder.LATEST_LAST_MESSAGE},Gd=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,E=e.hiddenChannelFilter,b=e.metadataOrderKeyFilter,w=e.metadataKey,C=e.metadataValues,x=e.metadataValueStartsWith,S=e.includeFrozen,T=e.includeMetaData,I=e.searchFilter,N=e.userIdsFilter;return(a=t.call(this)).method=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/my_group_channels"),a.params=ue({token:i,limit:o,order:null!=u?u:Fd.order,show_member:!0,show_read_receipt:!0,show_delivery_receipt:!0,show_empty:null!=c?c:Fd.includeEmpty,member_state_filter:null!=l?l:Fd.myMemberStateFilter,super_mode:null!=h?h:Fd.superChannelFilter,public_mode:null!=d?d:Fd.publicChannelFilter,unread_filter:null!=f?f:Fd.unreadChannelFilter,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:E,metadata_order_key:b,metadata_key:w,metadata_values:C,metadata_value_startswith:x,show_frozen:S,show_metadata:T}),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)}(Oe),qd=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).channels=[];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 Kp(e,t)}))),s.ts=null!=u?u:0,s}return s(n)}(Ue),Hd=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=le.GET,s.path="".concat(de,"/").concat(encodeURIComponent(i),"/group_channel_count"),s.params={state:null!=u?u:e.MyMemberStateFilter.ALL},s}return s(a)}(Oe),jd=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)}(Ue),zd=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=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/unread_item_count"),a.params=ue({item_keys:o}),a}return s(n)}(Oe),Vd=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)}(Ue),Bd=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=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/unread_channel_count"),a}return s(n)}(Oe),Qd=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)}(Ue),Kd=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=le.GET,s.path="".concat(de,"/").concat(encodeURIComponent(i),"/unread_message_count"),s.params={super_mode:null!=c?c:e.SuperChannelFilter.ALL,custom_types:u},s}return s(a)}(Oe),Wd=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)}(Ue),Yd=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=le.GET,a.path="".concat(we,"/count"),a.params={channel_url:s,status:Jd(i)},o&&(a.params.message_type=o),a}return s(n)}(Oe),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)).count=a.count,s}return s(n)}(Ue),Jd=function(t){if(!t)return[];var n=[];return t.forEach((function(t){switch(t){case e.ScheduledStatus.PENDING:n.push(ys.PENDING);break;case e.ScheduledStatus.SENT:n.push(ys.IN_QUEUE),n.push(ys.SENT);break;case e.ScheduledStatus.CANCELED:n.push(ys.CANCELED);break;case e.ScheduledStatus.FAILED:n.push(ys.FAILED)}})),n},Xd=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,E=e.customType,b=e.messageSurvivalSeconds,w=e.invitedUserIds,C=e.operatorUserIds;return(a=t.call(this)).method=le.POST,a.path=pe,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:E,operator_ids:C,message_survival_seconds:b}),a}return s(n)}(Oe),$d=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)).channel=new Kp(e,a),s.isCreated=null===(i=a.is_created)||void 0===i||i,s}return s(n)}(Ue),ef=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=le.PUT,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/mark_as_read_all"),a.params={channel_urls:i},a}return s(n)}(Oe),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,"SYEV",s)).event=new gd(s),i}return s(n)}(qe),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.accessCode;return(a=t.call(this)).method=le.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(s),"/join"),a.params={user_id:i,access_code:o},a}return s(n)}(Oe),rf=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 Kp(e,a),s}return s(n)}(Ue),af=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?0:u,l=o.joined_member_count,h=void 0===l?0: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 dd(e,t)})):[new dd(e,s.data)],i}return s(n)}(tf),sf=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=le.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(s),"/leave"),a.params={user_id:i,should_remove_operator_status:o},a}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?0:u,l=o.joined_member_count,h=void 0===l?0:l;return i.memberCount=c,i.joinedMemberCount=h,i.member=new dd(i._iid,s.data),i}return s(n)}(tf),uf=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=le.POST,a.path="".concat(pe,"/").concat(encodeURIComponent(s),"/invite"),a.params={user_ids:i},a}return s(n)}(Oe),cf=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 Kp(e,a),s}return s(n)}(Ue),lf=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?0:u,l=o.joined_member_count,h=void 0===l?0:l,d=o.inviter,f=o.invitees,p=void 0===f?[]:f;return i.memberCount=c,i.joinedMemberCount=h,i.inviter=new Xa(e,d),i.invitees=p.map((function(t){return new dd(e,t)})),i}return s(n)}(tf),hf=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=le.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(s),"/decline"),a.params={user_id:i},a}return s(n)}(Oe),df=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=o.joined_member_count,l=o.inviter,h=o.invitee;return i.memberCount=null!=u?u:0,i.joinedMemberCount=null!=c?c:0,i.inviter=new Xa(e,l),i.invitee=new dd(e,h),i}return s(n)}(tf),ff=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)}(oa),pf=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 fd(e,s),i}return s(n)}(qe),vf=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=le.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(s),"/messages/mark_as_delivered"),a.params=ue({userId:i}),a}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,"DLVR",s)).channelUrl=s.channel_url,i.deliveredStateUpdate=s.updated,i}return s(n)}(qe),mf={hidePreviousMessages:!1,allowAutoUnhide:!0},gf=function(e){return L("boolean",e.hidePreviousMessages,!0)&&L("boolean",e.allowAutoUnhide,!0)},yf=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=le.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(s),"/hide"),a.params={user_id:i,hide_previous_messages:null!=o?o:mf.hidePreviousMessages,allow_auto_unhide:null!=u?u:mf.allowAutoUnhide},a}return s(n)}(Oe),kf=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.ts_message_offset;return s.messageOffsetTimestamp=i,s}return s(n)}(Ue),Ef=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c;return r(this,n),(i=t.call(this,e,"SYEV",s)).allowAutoUnhide=null,i.hidePreviousMessages=null,i.messageOffsetTimestamp=null,s.data&&(i.allowAutoUnhide=null!==(o=s.data.allow_auto_unhide)&&void 0!==o?o:null,i.hidePreviousMessages=null!==(u=s.data.hide_previous_messages)&&void 0!==u?u:null),i.messageOffsetTimestamp=null!==(c=s.ts_message_offset)&&void 0!==c?c:null,i}return s(n)}(qe),bf=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)}(oa),wf=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 Xa(e,s.data),i}return s(n)}(qe),Cf=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)}(oa),xf=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 Xa(e,s.data),i}return s(n)}(qe),Sf=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 Xa(i._iid,e)})),i}return s(n)}(tf),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,"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)}(qe),If=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)}(oa),Nf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l;r(this,n),(i=t.call(this,e,"ADMM",s)).message=new Rs(e,s);var h=fs.of(e).sdkState;return i.isMentioned=Ie(i.message.mentionType,null!==(c=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})))&&void 0!==c?c:[],h.userId),i.forceUpdateLastMessage=null!==(l=s.force_update_last_message)&&void 0!==l&&l,i}return s(n)}(qe),Mf=function(e){i(n,e);var t=f(n);function n(e,a,s){var i,o,u,c,l,h;r(this,n),(i=t.call(this,e,"AEDI",s)).message=new Rs(e,s);var d=fs.of(e).sdkState;return i.mentionCountChange=Ne({mentionType:null===(o=s.old_values)||void 0===o?void 0:o.mention_type,mentionedUserIds:null!==(c=null===(u=s.old_values)||void 0===u?void 0:u.mentioned_user_ids)&&void 0!==c?c:[]},ce({mentionType:i.message.mentionType,mentionedUserIds:null!==(l=i.message.mentionedUserIds)&&void 0!==l?l:null===(h=i.message.mentionedUsers)||void 0===h?void 0:h.map((function(e){return e.userId}))}),d.userId),i}return s(n)}(qe),Af=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 ks(s),i}return s(n)}(qe),Of=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)}(qe),Uf=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=new ro(e,s),i.status=Ps(s.poll.status)||s.poll.status,i.channelUrl=s.channel_url,i.channelType=s.channel_type,i}return s(n)}(qe),Rf=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,E,b,w,C,x,S,T,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!==(E=n.hiddenChannelFilter)&&void 0!==E?E:e.HiddenChannelFilter.UNHIDDEN,s.searchFilter=null!==(b=n.searchFilter)&&void 0!==b?b:{fields:[],query:null},s.userIdsFilter=null!==(w=n.userIdsFilter)&&void 0!==w?w:{userIds:[],includeMode:!0,queryType:e.QueryType.AND},s.metadataKey=null!==(C=n.metadataKey)&&void 0!==C?C:null,s.metadataValues=null!==(x=n.metadataValues)&&void 0!==x?x:null,s.metadataOrderKeyFilter=null!==(S=n.metadataOrderKeyFilter)&&void 0!==S?S:null,s.metadataValueStartsWith=null!==(T=n.metadataValueStartsWith)&&void 0!==T?T: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 Wa(this)}},{key:"next",value:function(){return E(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=Ff.of(this._iid),e.next=7,n.getMyGroupChannels(this._token,ce(Object.assign({},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}(Ii),Lf=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||H.unreadMentionCount>0)&&(H._updateUnreadCount(0,0),this._dispatcher.dispatch(new du({channels:[H],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),Ca((function(){return E(dn,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._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onChannelChanged&&a.onChannelChanged(H)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):0!==H.unreadMessageCount&&0!==H.unreadMentionCount||(this._dispatcher.dispatch(new du({channels:[H],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),Ca((function(){return E(dn,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._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onChannelChanged&&a.onChannelChanged(H)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))):(this._dispatcher.dispatch(new du({channels:[H],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ})),Ca((function(){return E(dn,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._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onUnreadMemberStatusUpdated&&a.onUnreadMemberStatusUpdated(H)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))})));case 80:return a.abrupt("break",337);case 81:return j=n.as(_f),z=j.channelUrl,V=j.deliveredStateUpdate,B=void 0===V?{}:V,Q=this._groupChannelCache.isCachedInMemory(z),a.next=85,this.getChannel(z,!0);case 85:if(K=a.sent,Q)for(W in B)K._updateUndeliveredMemberState(W,B[W]);return Object.keys(B).some((function(e){return e!==dn._sdkState.userId}))&&(this._dispatcher.dispatch(new du({channels:[K],source:e.GroupChannelEventSource.EVENT_CHANNEL_DELIVERED})),Ca((function(){return E(dn,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._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onUndeliveredMemberStatusUpdated&&a.onUndeliveredMemberStatusUpdated(K)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",337);case 89:if(Y=n.as(Af),Z=Y.channelUrl,J=Y.channelType,X=Y.event,J!==e.ChannelType.GROUP){a.next=99;break}return a.next=93,this.getChannel(Z,!0);case 93:return $=a.sent,a.next=96,this.getMessageFromCache(X.messageId);case 96:(ee=a.sent)&&(ee.applyReactionEvent(X),this._dispatcher.dispatch(new ui({messages:[ee],source:e.MessageEventSource.EVENT_MESSAGE_REACTION_UPDATED}))),Ca((function(){return E(dn,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._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onReactionUpdated&&a.onReactionUpdated($,X)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 99:return a.abrupt("break",337);case 100:if(te=n.as(Of),(ne=te.event).channelType!==e.ChannelType.GROUP){a.next=110;break}return a.next=104,this.getChannel(ne.channelUrl,!0);case 104:return re=a.sent,a.next=107,this.getMessageFromCache(ne.targetMessageId);case 107:(ae=a.sent)&&(ae.applyThreadInfoUpdateEvent(ne),this._dispatcher.dispatch(new ui({messages:[ae],source:e.MessageEventSource.EVENT_MESSAGE_THREADINFO_UPDATED}))),Ca((function(){return E(dn,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._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onThreadInfoUpdated&&a.onThreadInfoUpdated(re,ne)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 110:return a.abrupt("break",337);case 111:se=n.as(Tf),ie=se.groupChannelMemberCounts,oe=[],ue=y(ie),a.prev=114,ue.s();case 116:if((ce=ue.n()).done){a.next=125;break}return le=ce.value,he=le.channelUrl,de=le.memberCount,fe=le.joinedMemberCount,pe=le.updatedAt,a.next=121,this.getChannelFromCache(he);case 121:(ve=a.sent)&&ve._setLatestMemberCount(de,fe,pe)&&oe.push(ve);case 123:a.next=116;break;case 125:a.next=130;break;case 127:a.prev=127,a.t2=a.catch(114),ue.e(a.t2);case 130:return a.prev=130,ue.f(),a.finish(130);case 133:return oe.length>0&&(this._dispatcher.dispatch(new du({channels:oe,source:e.GroupChannelEventSource.EVENT_CHANNEL_MEMBER_COUNT_UPDATED})),Ca((function(){return E(dn,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._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onChannelMemberCountChanged&&a.onChannelMemberCountChanged(oe)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",337);case 135:if(_e=n.as(Uf),me=_e.event,ge=_e.status,ye=_e.channelUrl,ke=_e.channelType,!ye||ke!==e.ChannelType.GROUP){a.next=142;break}return a.next=139,this.getChannel(ye,!0);case 139:Ee=a.sent,this._dispatcher.dispatch(new di({event:me,source:e.MessageEventSource.EVENT_POLL_UPDATED})),Ca(ge===Ds?function(){return E(dn,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._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onPollDeleted&&a.onPollDeleted(Ee,me.pollId)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return E(dn,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._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onPollUpdated&&a.onPollUpdated(Ee,me)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))});case 142:return a.abrupt("break",337);case 143:if(be=n.as(td),we=be.event,Ce=be.channelUrl,xe=be.channelType,!Ce||xe!==e.ChannelType.GROUP){a.next=150;break}return a.next=147,this.getChannel(Ce,!0);case 147:Se=a.sent,this._dispatcher.dispatch(new fi({event:we,source:e.MessageEventSource.EVENT_POLL_VOTED})),Ca((function(){return E(dn,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._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onPollVoted&&a.onPollVoted(Se,we)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}));case 150:return a.abrupt("break",337);case 151:if(Te=n.as(tf),!(Ie=Te.event).isGroupChannelEvent){a.next=325;break}a.t3=Ie.category,a.next=a.t3===pd.CHANNEL_JOIN?156:a.t3===pd.CHANNEL_LEAVE?165:a.t3===pd.CHANNEL_OPERATOR_UPDATE?181:a.t3===pd.CHANNEL_INVITE?192:a.t3===pd.CHANNEL_DECLINE_INVITE?202:a.t3===pd.TYPING_START||a.t3===pd.TYPING_END?210:a.t3===pd.USER_CHANNEL_MUTE||a.t3===pd.USER_CHANNEL_UNMUTE?219:a.t3===pd.USER_CHANNEL_BAN?246:a.t3===pd.USER_CHANNEL_UNBAN?261:a.t3===pd.CHANNEL_FREEZE||a.t3===pd.CHANNEL_UNFREEZE?267:a.t3===pd.CHANNEL_HIDE?275:a.t3===pd.CHANNEL_UNHIDE?285:a.t3===pd.CHANNEL_DELETED?292:a.t3===pd.CHANNEL_PROP_CHANGED?298:a.t3===pd.CHANNEL_META_DATA_CHANGED?304:a.t3===pd.CHANNEL_META_COUNTERS_CHANGED?313:a.t3===pd.PINNED_MESSAGE_CHANGED?319:325;break;case 156:return a.next=158,this.getChannel(Ie.channelUrl,!0);case 158:return Ne=a.sent,Me=n.as(af),Ae=Me.memberCount,Oe=Me.joinedMemberCount,Ue=Me.members,Re=!1,Ue.forEach((function(t){Ne.isExclusive||Ne.isSuper||Ne.isBroadcast?Re=Re||Ne._setLatestMemberCount(Ae,Oe,Ie.ts):(t.state=e.MemberState.JOINED,Ne.addMember(t,Ie.ts),dn._updateJoinedMemberCount(Ne)),t.userId===dn._sdkState.userId&&(Ne.myMemberState=e.MemberState.JOINED)})),this._dispatcher.dispatch(new du({channels:[Ne],source:e.GroupChannelEventSource.EVENT_CHANNEL_JOINED})),Ca((function(){return E(dn,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(Ue);try{for(n.s();!(t=n.n()).done;){var r=t.value;e.onUserJoined&&e.onUserJoined(Ne,r)}}catch(e){n.e(e)}finally{n.f()}Ne.isBroadcast&&Re&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([Ne])}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",325);case 165:if(!(Le=this._leftChannels.get(Ie.channelUrl))){a.next=170;break}a.t4=Le.channel,a.next=173;break;case 170:return a.next=172,this.getChannel(Ie.channelUrl,!0);case 172:a.t4=a.sent;case 173:return De=a.t4,Pe=n.as(of),Fe=Pe.memberCount,Ge=Pe.joinedMemberCount,qe=Pe.member,He=!1,je=fs.of(this._iid),ze=je.appInfo,De.isExclusive||De.isSuper||De.isBroadcast?He=De._setLatestMemberCount(Fe,Ge,Ie.ts):((null==ze?void 0:ze.enabledChannelMemberShipHistory)?((Ve=De.members.find((function(e){return e.userId===Ve.userId})))&&(Ve.state=e.MemberState.LEFT),De.memberCount=Fe):De.removeMember(qe),this._updateJoinedMemberCount(De)),qe.userId===this._sdkState.userId?(De.myMemberState=e.MemberState.NONE,De.invitedAt=0,De.joinedAt=0,De._updateUnreadCount(0,0),De.isPublic?this._dispatcher.dispatch(new du({channels:[De],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})):(this._markAsLeave(De),this._dispatcher.dispatch(new fu({channelUrls:[De.url],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})))):this._dispatcher.dispatch(new du({channels:[De],source:e.GroupChannelEventSource.EVENT_CHANNEL_LEFT})),Ca((function(){return E(dn,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&&e.onUserLeft(De,qe),De.isBroadcast&&He&&e.onChannelMemberCountChanged&&e.onChannelMemberCountChanged([De])}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",325);case 181:return a.next=183,this.getChannel(Ie.channelUrl,!0);case 183:Be=a.sent,Qe=n.as(Sf),Ke=Qe.operators,We=Ke.map((function(e){return e.userId})),Ye=y(Be.members);try{for(Ye.s();!(Ze=Ye.n()).done;)(Je=Ze.value).role=We.includes(Je.userId)?e.Role.OPERATOR:e.Role.NONE}catch(e){Ye.e(e)}finally{Ye.f()}return Be.myRole=We.includes(this._sdkState.userId)?e.Role.OPERATOR:e.Role.NONE,this._dispatcher.dispatch(new du({channels:[Be],source:e.GroupChannelEventSource.EVENT_CHANNEL_OPERATOR_UPDATED})),Ca((function(){return E(dn,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&&e.onOperatorUpdated(Be,Ke)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",325);case 192:return a.next=194,this.getChannel(Ie.channelUrl,!0);case 194:Xe=a.sent,$e=n.as(lf),et=$e.memberCount,tt=$e.joinedMemberCount,nt=$e.inviter,(rt=$e.invitees).forEach((function(t){return t.state=e.MemberState.INVITED})),at=y(rt);try{for(at.s();!(st=at.n()).done;)it=st.value,Xe.isExclusive||Xe.isSuper||Xe.isBroadcast?Xe._setLatestMemberCount(et,tt,Ie.ts):Xe.addMember(it,Ie.ts),this._sdkState.userId===it.userId&&(Xe.hiddenState=e.HiddenState.UNHIDDEN,Xe.myMemberState!==e.MemberState.JOINED&&(Xe.myMemberState=e.MemberState.INVITED),Xe.invitedAt=Ie.ts)}catch(e){at.e(e)}finally{at.f()}return this._dispatcher.dispatch(new du({channels:[Xe],source:e.GroupChannelEventSource.EVENT_CHANNEL_INVITED})),Ca((function(){return E(dn,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&&e.onUserReceivedInvitation(Xe,nt,rt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",325);case 202:return a.next=204,this.getChannel(Ie.channelUrl,!0);case 204:return ot=a.sent,ut=n.as(df),ct=ut.memberCount,lt=ut.joinedMemberCount,ht=ut.inviter,dt=ut.invitee,ot.isExclusive||ot.isSuper||ot.isBroadcast?ot._setLatestMemberCount(ct,lt,Ie.ts):ot.removeMember(dt),this._sdkState.userId===dt.userId?(ot.invitedAt=0,ot.myMemberState=e.MemberState.NONE,ot.isPublic?this._dispatcher.dispatch(new du({channels:[ot],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE})):this._dispatcher.dispatch(new fu({channelUrls:[ot.url],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE}))):this._dispatcher.dispatch(new du({channels:[ot],source:e.GroupChannelEventSource.EVENT_CHANNEL_DECLINED_INVITE})),Ca((function(){return E(dn,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&&e.onUserDeclinedInvitation(ot,ht,dt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",325);case 210:return a.next=212,this.getChannel(Ie.channelUrl,!0);case 212:return ft=a.sent,pt=Ie.category===pd.TYPING_START,vt=n.as(pt?wf:xf),_t=vt.user,ft._updateTypingStatus(_t,pt?Ie.ts:0),this._dispatcher.dispatch(new du({channels:[ft],source:e.GroupChannelEventSource.EVENT_CHANNEL_TYPING_STATUS_UPDATE})),Ca((function(){return E(dn,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&&e.onTypingStatusUpdated(ft)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",325);case 219:return a.next=221,this.getChannel(Ie.channelUrl,!0);case 221:mt=a.sent,gt=Ie.category===pd.USER_CHANNEL_MUTE,yt=n.as(gt?fh:vh),(kt=yt.user).userId===this._sdkState.userId&&(mt.myMutedState=gt?e.MutedState.MUTED:e.MutedState.UNMUTED,mt._myMutedRemainingTime=kt.restrictionInfo.remainingDuration),Et=y(mt.members),a.prev=226,Et.s();case 228:if((bt=Et.n()).done){a.next=235;break}if((wt=bt.value).userId!==kt.userId){a.next=233;break}return wt.isMuted=gt,a.abrupt("break",235);case 233:a.next=228;break;case 235:a.next=240;break;case 237:a.prev=237,a.t5=a.catch(226),Et.e(a.t5);case 240:return a.prev=240,Et.f(),a.finish(240);case 243:return this._dispatcher.dispatch(new du({channels:[mt],source:gt?e.GroupChannelEventSource.EVENT_CHANNEL_MUTED:e.GroupChannelEventSource.EVENT_CHANNEL_UNMUTED,data:kt.userId})),Ca((function(){return E(dn,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){gt?e.onUserMuted&&e.onUserMuted(mt,kt):e.onUserUnmuted&&e.onUserUnmuted(mt,kt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",325);case 246:if(!(Ct=this._leftChannels.get(Ie.channelUrl))){a.next=251;break}a.t6=Ct.channel,a.next=254;break;case 251:return a.next=253,this.getChannel(Ie.channelUrl,!0);case 253:a.t6=a.sent;case 254:return xt=a.t6,this._markAsLeave(xt),St=n.as(mh),Tt=St.user,Tt.userId===this._sdkState.userId&&this._dispatcher.dispatch(new fu({channelUrls:[xt.url],source:e.GroupChannelEventSource.EVENT_CHANNEL_BANNED})),Ca((function(){return E(dn,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&&e.onUserBanned(xt,Tt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",325);case 261:return a.next=263,this.getChannel(Ie.channelUrl,!0);case 263:return It=a.sent,Nt=n.as(yh),Mt=Nt.user,Ca((function(){return E(dn,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&&e.onUserUnbanned(It,Mt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",325);case 267:return a.next=269,this.getChannel(Ie.channelUrl,!0);case 269:return At=a.sent,Ot=n.as(Eh),Ut=Ot.freeze,At.isFrozen=Ut,this._dispatcher.dispatch(new du({channels:[At],source:Ut?e.GroupChannelEventSource.EVENT_CHANNEL_FROZEN:e.GroupChannelEventSource.EVENT_CHANNEL_UNFROZEN})),Ca((function(){return E(dn,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){Ut?e.onChannelFrozen&&e.onChannelFrozen(At):e.onChannelUnfrozen&&e.onChannelUnfrozen(At)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",325);case 275:return a.next=277,this.getChannel(Ie.channelUrl,!0);case 277:return Rt=a.sent,Lt=n.as(Ef),Dt=Lt.allowAutoUnhide,Pt=Lt.hidePreviousMessages,Ft=Lt.messageOffsetTimestamp,null!==Dt&&(Rt.hiddenState=Dt?e.HiddenState.HIDDEN_ALLOW_AUTO_UNHIDE:e.HiddenState.HIDDEN_PREVENT_AUTO_UNHIDE),null!==Pt&&Pt&&Rt._updateUnreadCount(0,0),null!==Ft&&(Rt.messageOffsetTimestamp=Ft),this._dispatcher.dispatch(new du({channels:[Rt],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN})),Ca((function(){return E(dn,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&&e.onChannelHidden(Rt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",325);case 285:return a.next=287,this.getChannel(Ie.channelUrl,!0);case 287:return(Gt=a.sent).hiddenState=e.HiddenState.UNHIDDEN,this._dispatcher.dispatch(new du({channels:[Gt],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN})),Ca((function(){return E(dn,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&&e.onChannelChanged(Gt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",325);case 292:return a.next=294,this.getChannel(Ie.channelUrl,!0);case 294:return qt=a.sent,this._dispatcher.dispatch(new fu({channelUrls:[Ie.channelUrl],source:e.GroupChannelEventSource.EVENT_CHANNEL_DELETED})),Ca((function(){return E(dn,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&&e.onChannelDeleted(qt.url,qt.channelType)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",325);case 298:return a.next=300,this.getChannelWithoutCache(Ie.channelUrl,!0);case 300:return Ht=a.sent,this._dispatcher.dispatch(new du({channels:[Ht],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED})),Ca((function(){return E(dn,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&&e.onChannelChanged(Ht)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",325);case 304:return a.next=306,this.getChannel(Ie.channelUrl,!0);case 306:return jt=a.sent,zt=n.as(Xl),Vt=zt.created,Bt=zt.updated,Qt=zt.deleted,Vt&&jt._upsertCachedMetaData(Vt,Ie.ts),Bt&&jt._upsertCachedMetaData(Bt,Ie.ts),Qt&&jt._removeFromCachedMetaData(Qt,Ie.ts),Ca((function(){return E(dn,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.onMetaDataCreated&&e.onMetaDataCreated(jt,Vt),Bt&&e.onMetaDataUpdated&&e.onMetaDataUpdated(jt,Bt),Qt&&e.onMetaDataDeleted&&e.onMetaDataDeleted(jt,Qt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",325);case 313:return a.next=315,this.getChannel(Ie.channelUrl,!0);case 315:return Kt=a.sent,Wt=n.as(ch),Yt=Wt.created,Zt=Wt.updated,Jt=Wt.deleted,Ca((function(){return E(dn,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){Yt&&e.onMetaCounterCreated&&e.onMetaCounterCreated(Kt,Yt),Zt&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Kt,Zt),Jt&&e.onMetaCounterDeleted&&e.onMetaCounterDeleted(Kt,Jt)}));case 1:case"end":return e.stop()}}),e,this)})))})),a.abrupt("break",325);case 319:return a.next=321,this.getChannel(Ie.channelUrl,!0);case 321:return Xt=a.sent,$t=n.as(Df),en=$t.pinnedMessageIds,tn=$t.latestPinnedMessage,(nn=$t.ts)>Xt._pinnedMessagesUpdatedAt&&(Xt.pinnedMessageIds=en,Xt.lastPinnedMessage=tn,Xt._pinnedMessagesUpdatedAt=nn,this._dispatcher.dispatch(new du({channels:[Xt],source:e.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED})),Ca((function(){return E(dn,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._groupChannelHandlers.values());try{for(n.s();!(r=n.n()).done;)(a=r.value).onChannelChanged&&a.onChannelChanged(Xt)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))})),Ca((function(){return E(dn,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&&e.onPinnedMessageUpdated(Xt)}));case 1:case"end":return e.stop()}}),e,this)})))}))),a.abrupt("break",325);case 325:return a.abrupt("break",337);case 326:rn=n.as(vu),an=rn.event,a.t7=an.category,a.next=a.t7===jo.USER_BLOCK?330:a.t7===jo.USER_UNBLOCK?333:336;break;case 330:return sn=uu.getDataAsUserBlockEvent(this._iid,an),on=sn.blocker,un=sn.blockee,this._groupChannelCache.block(on.userId,un.userId),a.abrupt("break",336);case 333:return cn=uu.getDataAsUserBlockEvent(this._iid,an),ln=cn.blocker,hn=cn.blockee,this._groupChannelCache.unblock(ln.userId,hn.userId),a.abrupt("break",336);case 336:return a.abrupt("break",337);case 337:a.next=343;break;case 339:if(a.prev=339,a.t8=a.catch(0),!M(a.t8)){a.next=343;break}throw a.t8;case 343:case"end":return a.stop()}}),a,this,[[0,339],[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 E(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 Za(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 E(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 Za(L("string",n)).throw(A.invalidParameters),s=new Dd({channelUrl:n,isInternalCall:r}),t.next=4,this._requestQueue.send(s);case 4:i=t.sent,o=i.as(Pd),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 E(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 Dd({channelUrl:n,isInternalCall:r}),t.next=4,this._requestQueue.send(i);case 4:if(o=t.sent,u=o.as(Pd),(c=u.channel).myMemberState!==e.MemberState.NONE){t.next=10;break}this._dispatcher.dispatch(new fu({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 du({channels:l,source:a}));case 14:t.next=19;break;case 16:t.prev=16,t.t0=t.catch(0),t.t0.code!==b.NON_AUTHORIZED&&t.t0.code!==b.NOT_FOUND_IN_DATABASE||this._dispatcher.dispatch(new fu({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 E(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 Gd(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(qd),c=u.channels,l=u.token,this._dispatcher.dispatch(new du({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){var n;return E(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._messageCache.get(e);case 2:if(t.t1=n=t.sent,t.t0=null!==t.t1,!t.t0){t.next=6;break}t.t0=void 0!==n;case 6:if(!t.t0){t.next=10;break}t.t2=n,t.next=11;break;case 10:t.t2=null;case 11:return t.abrupt("return",t.t2);case 12:case"end":return t.stop()}}),r,this)})))}},{key:"_getExactlyMatchingMessagesForTokenFromCache",value:function(e,n,r){return E(this,void 0,void 0,t().mark((function a(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._messageCache.fetch({channelUrl:e,token:n,filter:r,exactMatch:!0});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),a,this)})))}},{key:"getMessagesFromCache",value:function(e,n,r,a){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:yo,i=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];return E(this,void 0,void 0,t().mark((function o(){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,inclusive:i});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),o,this)})))}},{key:"getPollMessagesFromCache",value:function(e,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:yo;return E(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 E(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 E(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 E(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 Lf({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 E(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({},Ed),r),Za((L("string",n)||L("number",n))&&bd(s)).throw(A.invalidParameters),i=new Rd(ce({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(Ld),c=u.updatedChannels,l=u.deletedChannelUrls,h=u.hasMore,c.length>0&&this._dispatcher.dispatch(new du({channels:c,source:a})),l.length>0&&this._dispatcher.dispatch(new fu({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 E(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({},wd),e),Za(Cd(r)).throw(A.invalidParameters),a=new Hd({userId:this._sdkState.userId,filter:r}),t.next=5,this._requestQueue.send(a);case 5:return s=t.sent,i=s.as(jd),o=i.groupChannelCount,t.abrupt("return",o);case 8:case"end":return t.stop()}}),n,this)})))}},{key:"getUnreadItemCount",value:function(e){return E(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({},Sd),e),Za(Td(r)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new zd({userId:s.userId,filter:r}),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Vd),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 E(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=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Bd({userId:r.userId}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Qd),u=o.unreadCount,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"getTotalUnreadMessageCount",value:function(e){return E(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({},Id),e),Za(Nd(r)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new Kd({userId:s.userId,filter:r}),t.next=6,i.send(o);case 6:return u=t.sent,c=u.as(Wd),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 E(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({},Md),e),Za(Ad(r)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.requestQueue,i=new Yd(r),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(Zd),c=u.count,t.abrupt("return",c);case 9:case"end":return t.stop()}}),n,this)})))}},{key:"getSubscribedTotalUnreadMessageCount",value:function(){var e=fs.of(this._iid).subscribedUnreadMessageCount;return e.all>=0?e.all:0}},{key:"getSubscribedCustomTypeTotalUnreadMessageCount",value:function(){var e=0,t=fs.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=fs.of(this._iid).subscribedUnreadMessageCount.customTypes[e])&&void 0!==t?t:0}},{key:"createChannel",value:function(e){return E(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({},yd),e),Za(kd(r)).throw(A.invalidParameters),r.isPublic||(r.accessCode=void 0),a=new Xd(Object.assign({userId:this._sdkState.userId},r)),t.next=6,this._requestQueue.send(a);case 6:return s=t.sent,i=s.as($d),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 E(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(),Za(n-this._markAsReadAllLastSentAt>=1e3).throw(A.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=n,r=new ef({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 E(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(),Za(F("string",e)&&r-this._markAsReadAllLastSentAt>=1e3).throw(A.markAsReadAllRateLimitExceeded),this._markAsReadAllLastSentAt=r,a=new ef({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 E(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 Pf[e]}},{key:"clear",value:function(e){Pf[e]&&delete Pf[e]}}]),n}();!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.END=2]="END"}(xd||(xd={}));var Gf=function(e){i(a,e);var n=f(a);function a(e,t){var s;return r(this,a),(s=n.call(this))._state=xd.IDLE,s._retryCount=0,s._retryLimit=3,s.priority=0,s._worker=t,s}return s(a,[{key:"isIdle",get:function(){return this._state===xd.IDLE}},{key:"isRunning",get:function(){return this._state===xd.RUNNING}},{key:"isDone",get:function(){return this._state===xd.END}},{key:"retryCount",get:function(){return this._retryCount}},{key:"retryLimit",get:function(){return this._retryLimit}},{key:"_run",value:function(e){return E(this,void 0,void 0,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&&(f=h.map((function(e){return e.createdAt})),(null===(u=this._metadata)||void 0===u?void 0:(d=u.range).intersect.apply(d,_(f)))?this.extendRange(h):this._metadata={range:new Lf({top:Math.min.apply(Math,_(f)),bottom:Math.max.apply(Math,_(f))}),previousComplete:!1}),c.hasNext=h.length>=this._limit&&this._prevSyncLoopCount<1,this._metadata&&(c.nextToken=this._metadata.range.top,this._metadata.previousComplete=h.length0&&(d=l.map((function(e){return e.createdAt})),(null===(o=this._metadata)||void 0===o?void 0:(h=o.range).intersect.apply(h,_(d)))?this.extendRange(l):this._metadata={range:new Lf({top:Math.min.apply(Math,_(d)),bottom:Math.max.apply(Math,_(d))}),previousComplete:!1}),u.hasNext=l.length>=this._limit&&this._nextSyncLoopCount<1,this._metadata&&(u.nextToken=this._metadata.range.bottom),v.debug("message background next sync progress",u),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",u);case 23:case"end":return t.stop()}}),r,this,[[5,18]])})))})),this._connectionEventContext=p.on((function(e){if(e instanceof da)if(e.stateType===sa.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"range",get:function(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new Lf({})}},{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 E(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=fs.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=fs.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(){fs.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 jf[this._iid][this._channel.url])}}],[{key:"of",value:function(e,t){return jf[e]||(jf[e]={}),jf[e][t.url]||(jf[e][t.url]=new n({_iid:e,channel:t})),jf[e][t.url].ref++,jf[e][t.url]}},{key:"clear",value:function(e,t){jf[e]&&jf[e][t]&&(jf[e][t].close(),delete jf[e])}}]),n}(),Vf={},Bf=function(){function n(a){var s=this,i=a._iid,o=a.channel;r(this,n),this.ref=0,this._iid=i,this._channel=o;var u,c,l=fs.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 Gf(p,(function(){return E(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=wi.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&&(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 da)if(e.stateType===sa.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"loadMetadata",value:function(){return E(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=fs.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 E(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=fs.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 E(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=fs.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){var e=fs.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=fs.of(this._iid),t=e.logger;e.connectionManager,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 Vf[this._iid][this._channel.url])}}],[{key:"of",value:function(e,t){return Vf[e]||(Vf[e]={}),Vf[e][t.url]||(Vf[e][t.url]=new n({_iid:e,channel:t})),Vf[e][t.url].ref++,Vf[e][t.url]}},{key:"clear",value:function(e,t){Vf[e]&&Vf[e][t]&&(Vf[e][t].close(),delete Vf[e])}}]),n}(),Qf={},Kf=function(){function e(n){var a=this,s=n._iid,i=n.channel,o=n.hasPollMessage;r(this,e),this.ref=0,this._iid=s,this._channel=i;var u,c,l=fs.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 Gf(p,(function(){return E(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=fs.of(this._iid),i=s.firstConnectedAt,this._metadata={token:i}),e.prev=13,u=no.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 da)if(e.stateType===sa.CONNECTED)a.resume();else a.pause()}))}return s(e,[{key:"loadMetadata",value:function(){return E(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=fs.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}:void 0;case 6:case"end":return e.stop()}}),e,this)})))}},{key:"saveMetadata",value:function(){return E(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=fs.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 E(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=fs.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){fs.of(this._iid).logger.debug("poll changelog sync resume()"),this._sync.start(0)}},{key:"pause",value:function(){fs.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 Qf[this._iid][this._channel.url])}}],[{key:"of",value:function(t,n,r){return Qf[t]||(Qf[t]={}),Qf[t][n.url]||(Qf[t][n.url]=new e({_iid:t,channel:n,hasPollMessage:r})),Qf[t][n.url].ref++,Qf[t][n.url]}}]),e}(),Wf=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=le.GET,a.path="".concat(Se(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)}(Oe),Yf=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 Bs(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 Bs(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)}(Ue),Zf=function(t,n){var r,a,s,i;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;default:return null!==(i=null===(s=t.lastMessage)||void 0===s?void 0:s.createdAt)&&void 0!==i?i:t.createdAt}},Jf=function(e,t){return e.findIndex((function(e){return e.isIdentical(t)}))},Xf=function(e,t,n){if(e.length>0){for(var r=Jf(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:$f(e[i],t,n)>=0?i:i+1,oldPosition:r}}return{place:e.length,oldPosition:-1}},$f=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;default:return 0}},ep=function(e,t){return t instanceof Ms?e.findIndex((function(e){return e instanceof Ms&&t.isIdentical(e)})):e.findIndex((function(e){return e.isIdentical(t)}))},tp=function(e,t){return e.findIndex((function(e){return e.messageId===t}))},np=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},rp=6e5;e.MessageCollectionInitPolicy=void 0,(e.MessageCollectionInitPolicy||(e.MessageCollectionInitPolicy={})).CACHE_AND_REPLACE_BY_API="cache_and_replace_by_api";var ap,sp,ip,op=function(){function e(){r(this,e)}return s(e,[{key:"_invokeResponse",value:function(e,n,r){var a=this;Ca((function(){return E(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}(),up=function(){function n(a,s){var i=this,o=s.channel,u=s.filter,c=s.startingPoint,l=s.limit;r(this,n),this._messages=[],this._unsentMessages=[],this._iid=a,this._key="mc-".concat(re()),this._isDisposed=!1,this.filter=null!=u?u:new wo,this._channel=o,this._syncRange=new Lf({}),this._hasPrevious=!0,this._hasNext=!0,this._startingPoint="number"==typeof c?c:Date.now()+rp,this._limit=l||yo;var h=Ff.of(this._iid);h.subscribeGroupChannelEvent(this._key,{onUpdate:function(n,r,a){var s=Jf(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;fs.of(i._iid).sdkState.userId===h&&i._clearCheckMyMutedTimer();break;case e.GroupChannelEventSource.EVENT_CHANNEL_MUTED:var d=a;fs.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()}Ca((function(){return E(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 qf(r),hu(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(),Ca((function(){return E(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 qf(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(oi(n)){if(a.length>0)switch(n){case e.MessageEventSource.LOCAL_MESSAGE_CANCELED:case e.MessageEventSource.LOCAL_MESSAGE_RESEND_STARTED: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=fs.of(this._iid),f=d.cacheContext,p=d.dispatcher,v=d.logger;this._channel._updateMessageCollectionLastAccessedAt(),p.dispatch(new du({channels:[this._channel],source:e.GroupChannelEventSource.CHANNEL_LASTACCESSEDAT_UPDATED})),!this._channel.isSuper&&f.localCacheEnabled&&(this._backgroundSync=zf.of(this._iid,this._channel),this._backgroundSync.resume(this._startingPoint)),this._changelogSync=Bf.of(this._iid,this._channel),this._changelogSync.resume(),this._pollChangelogSync=Kf.of(this._iid,this._channel,this._hasPollMessage.bind(this)),this._pollChangelogSync.resume(),this._prevFill=new Gf(this._key,(function(n){return E(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 da)switch(n.stateType){case sa.CONNECTED:i._refreshChannel(e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS),xa((function(){return E(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 sa.LOGOUT:i.dispose();break;default:i._clearCheckMyMutedTimer(),i._prevFill.stop(),i._nextFill.stop()}})),fs.of(this._iid).statLogCollector.put(new ss({type:Ae.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(ep(this._messages,l)<0){ep(this._unsentMessages,l)<0&&o.push(l);var h=np(this._messages,l);this._messages.splice(h,0,l)}}else if(l instanceof Ms){ep(this._unsentMessages,l)<0&&ep(this._messages,l)<0&&(this._unsentMessages.push(l),o.push(l))}}else if(l.messageId>0){var d=ep(this._messages,l);if(d<0){var f=ep(this._unsentMessages,l);f<0?o.push(l):(this._unsentMessages.splice(f,1),u.push(l));var p=np(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 Ms){var m=ep(this._unsentMessages,l);m<0?ep(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()}oi(r)&&Ca((function(){return E(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 Hf(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.parentMessageId===e.messageId&&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=tp(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&&oi(n)&&Ca((function(){return E(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 Hf(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=tp(this._messages,e.messageId);if(a>=0){var s=this._messages[a];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollUpdateEvent(e)&&oi(n)&&Ca((function(){return E(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 Hf(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=tp(this._messages,e.messageId);if(a>=0){var s=this._messages[a];s&&s.isUserMessage()&&s.poll&&s.poll.applyPollVoteEvent(e)&&oi(n)&&Ca((function(){return E(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 Hf(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=[],u=y(e);try{for(u.s();!(r=u.n()).done;){var c=r.value;if(c.messageId>0){var l=ep(this._messages,c);if(l>=0)i.push(c),this._messages[l]=c;else{var h=ep(this._unsentMessages,c);if(h>=0){var d=this._unsentMessages.splice(h,1);if(this.hasNext&&d.length>0)o.push(d[0]);else{i.push(c);var f=np(this._messages,c);this._messages.splice(f,0,c)}}else{var p=this._messages.map((function(e){return e.createdAt}));(c.createdAtMath.max.apply(Math,_(p))&&!this._hasNext)&&s.push(c)}}}else if(c instanceof Ms){var v=ep(this._unsentMessages,c);v>=0&&(i.push(c),this._unsentMessages[v]=c)}}}catch(e){u.e(e)}finally{u.f()}return oi(n)&&Ca((function(){return E(a,void 0,void 0,t().mark((function e(){var r,a,u;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:u=new Hf(n),i.length>0?null===(r=this._handler)||void 0===r||r.onMessagesUpdated(u,this.channel,i):o.length>0?null===(a=this._handler)||void 0===a||a.onMessagesDeleted(u,this.channel,[],o):s.length>0&&this._addMessagesToView(s,n);case 2:case"end":return e.stop()}}),e,this)})))})),i}},{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 oi(n)&&i.length>0&&Ca((function(){return E(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 Hf(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,o=n.inclusive,u=void 0===o||o;return E(this,void 0,void 0,t().mark((function n(){var r,s,o,c;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=Ff.of(this._iid),s=[],!u){t.next=6;break}return t.next=5,r._getExactlyMatchingMessagesForTokenFromCache(this._channel.url,e,this.filter);case 5:s=t.sent;case 6:if(!(a>0)){t.next=12;break}return t.next=9,r.getMessagesFromCache(this._channel.url,e,"prev",this.filter,a,!1);case 9:t.t0=t.sent,t.next=13;break;case 12:t.t0=[];case 13:if(o=t.t0,!(i>0)){t.next=20;break}return t.next=17,r.getMessagesFromCache(this._channel.url,e,"next",this.filter,i,!1);case 17:t.t1=t.sent,t.next=21;break;case 20:t.t1=[];case 21:return c=t.t1,t.abrupt("return",[].concat(_(s),_(o),_(c)).sort((function(e,t){return t.createdAt-e.createdAt})));case 23:case"end":return t.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 E(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=wi.of(this._iid),!(s>0||o>0)){e.next=7;break}return e.next=4,r._getMessagesByTimestampForCollection(this._channel.url,this._channel.channelType,n,ce(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 E(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,C,x,S,T=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=Ff.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,wa((function(){return E(T,void 0,void 0,t().mark((function n(){var r,u,h,d,f,p,v,m,g,y,k,b,w,C,x,S,T,I,N,M,A,O=this;return t().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return u=fs.of(this._iid),h=u.dispatcher,d=u.requestQueue,f=u.cacheContext,p=new Wf(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(Yf),g=m.isHugeGap,y=m.prevMessages,k=void 0===y?[]:y,b=m.prevHasMore,w=m.isContinuousPrevMessages,C=m.nextMessages,x=void 0===C?[]:C,S=m.nextHasmore,T=m.isContinuousNextMessages,g?Ca((function(){return E(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)})))})):(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(_(x.map((function(e){return e.createdAt}))))),h.dispatch(new ui({messages:k,source:e.MessageEventSource.SYNC_MESSAGE_FILL})),h.dispatch(new ui({messages:x,source:e.MessageEventSource.SYNC_MESSAGE_FILL})),this._syncRange.extends(M,A),(w||T)&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(M,A)),b&&this._prevFill.start(M),S&&this._nextFill.start(A));case 7:case"end":return n.stop()}}),n,this)})))}),1);case 14:r.next=31;break;case 16:return h=fs.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,C=0,x=0;x=p&&C++;this._hasPrevious=w>=f,this._hasNext=C>=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===b.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 E(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=Ff.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 E(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=Ff.of(this._iid),e.next=3,n.getPollMessagesFromCache(this._channel.url,Date.now()+rp,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){Ff.of(this._iid).refreshChannel(this.channel.url,!0,e)}},{key:"_startCheckMyMutedTimer",value:function(n){var r=this;this._clearCheckMyMutedTimer(),this._checkMyMutedStateTimer=setTimeout((function(){return E(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=void 0,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 qf(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=void 0)}},{key:"initialize",value:function(n){var r=this,a=new op;this._messages=[],this._unsentMessages=[],this._syncRange=new Lf({}),this._hasNext=!0,this._hasPrevious=!0,this._refreshChannel(e.GroupChannelEventSource.REFRESH_CHANNEL),xa((function(){return E(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 E(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=fs.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;fr._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=fs.of(this._iid),o=i.cacheContext;return i.statLogCollector.put(new ss({type:Ae.FEATURE_LOCALCACHE,data:{use_local_cache:o.localCacheEnabled,collection_interface:{message_init_policy:n}}})),a}},{key:"loadPrevious",value:function(){return E(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:b.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(this._hasPrevious){n.next=4;break}return n.abrupt("return",[]);case 4:return r=Math.floor(this._limit/2),a=this.viewTop,s=[],n.next=9,xa((function(){return E(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(a,{prevLimit:r,inclusive:!1});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 9:if(!(s.length=r,s.length>0&&((l=this._syncRange).extends.apply(l,_(s.map((function(e){return e.createdAt})))),(null===(n=this._backgroundSync)||void 0===n?void 0:n.range.overlap(this._syncRange))&&c.isContinuousMessages&&(null===(i=this._backgroundSync)||void 0===i||i.range.extends(this._syncRange.top)));case 8:case"end":return e.stop()}}),e,this)})))}));case 12:this._addMessagesToView(s,e.MessageEventSource.REQUEST_MESSAGE),n.next=17;break;case 15:this._hasPrevious=s.length>=r,s.length>0&&this._addMessagesToView(s,e.MessageEventSource.REQUEST_MESSAGE);case 17:return n.abrupt("return",s);case 18:case"end":return n.stop()}}),n,this)})))}},{key:"loadNext",value:function(){var n;return E(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._isDisposed){r.next=2;break}throw new A({code:b.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(this._hasNext){r.next=4;break}return r.abrupt("return",[]);case 4:return a=Math.floor(this._limit/2),s=this.viewBottom,i=[],r.next=9,xa((function(){return E(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(s,{nextLimit:a,inclusive:!1});case 3:e.t1=e.sent,i=e.t0._filterUnderOffsetMessage.call(e.t0,e.t1);case 5:case"end":return e.stop()}}),e,this)})))}));case 9:if(!(i.length=a,i.length>0&&((l=this._syncRange).extends.apply(l,_(i.map((function(e){return e.createdAt})))),(null===(n=this._backgroundSync)||void 0===n?void 0:n.range.overlap(this._syncRange))&&c.isContinuousMessages&&(null===(r=this._backgroundSync)||void 0===r||r.range.extends(this._syncRange.bottom)));case 8:case"end":return e.stop()}}),e,this)})))}));case 12:this._addMessagesToView(i,e.MessageEventSource.REQUEST_MESSAGE),r.next=17;break;case 15:this._hasNext=i.length>=a,i.length>0&&this._addMessagesToView(i,e.MessageEventSource.REQUEST_MESSAGE);case 17:return r.abrupt("return",i);case 18:case"end":return r.stop()}}),r,this)})))}},{key:"removeFailedMessage",value:function(e){return E(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._isDisposed){t.next=2;break}throw new A({code:b.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:return r=Ff.of(this._iid),t.next=5,r.removeFailedMessageFromCache(e);case 5:(a=this._unsentMessages.findIndex((function(t){return t.reqId===e})))>-1&&this._unsentMessages.splice(a,1);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"dispose",value:function(){var t,n,r;if(!this._isDisposed){this._isDisposed=!0;var a=fs.of(this._iid),s=a.cacheContext,i=a.dispatcher;this._messages=[],this._clearCheckMyMutedTimer(),this._channel._updateMessageCollectionLastAccessedAt(),i.dispatch(new du({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=Ff.of(this._iid);o.unsubscribeGroupChannelEvent(this._key),o.unsubscribeMessageEvent(this._key),this._connectionEventContext&&this._connectionEventContext.close()}}}]),n}(),cp={coverUrl:void 0,coverImage:void 0,isDistinct:void 0,isPublic:void 0,isDiscoverable:void 0,accessCode:void 0,name:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,messageSurvivalSeconds:void 0},lp=function(e){return L("string",e.coverUrl,!0)&&(q(e.coverImage)||L("string",e.coverImage,!0))&&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)},hp=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=le.GET,a.path="".concat(pe,"/").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)}(Oe),dp=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).members=[];var i=a.next,o=a.members;return s.token=i,o&&o.length>0&&(s.members=o.map((function(t){return new dd(e,t)}))),s}return s(n)}(Ue);e.MutedMemberFilter=void 0,(ap=e.MutedMemberFilter||(e.MutedMemberFilter={})).ALL="all",ap.MUTED="muted",ap.UNMUTED="unmuted",e.MemberListOrder=void 0,(sp=e.MemberListOrder||(e.MemberListOrder={})).MEMBER_NICKNAME_ALPHABETICAL="member_nickname_alphabetical",sp.OPERATOR_THEN_MEMBER_ALPHABETICAL="operator_then_member_alphabetical",e.MemberStateFilter=void 0,(ip=e.MemberStateFilter||(e.MemberStateFilter={})).ALL="all",ip.JOINED="joined_only",ip.INVITED="invited_only",ip.INVITED_BY_FRIEND="invited_by_friend",ip.INVITED_BY_NON_FRIEND="invited_by_non_friend";var fp,pp,vp,_p=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 E(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=fs.of(this._iid),r=n.requestQueue,a=new hp(ce(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(dp),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}(Li),mp=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=le.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(s),"/accept"),a.params={user_id:i,access_code:o},a}return s(n)}(Oe),gp=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 Kp(t,s),i.channel.myMemberState=e.MemberState.JOINED,i}return s(a)}(Ue),yp=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=le.PUT,a.path="".concat(pe,"/").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)}(Oe),kp=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 Kp(e,a),s}return s(n)}(Ue),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=le.DELETE,a.path="".concat(pe,"/").concat(encodeURIComponent(s)),a}return s(n)}(Oe),bp=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=le.DELETE,a.path="".concat(pe,"/").concat(encodeURIComponent(s),"/hide"),a}return s(n)}(Oe),wp=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=le.PUT,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/count_preference/").concat(encodeURIComponent(i)),a.params={count_preference:o},a}return s(n)}(Oe),Cp=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)}(Ue),xp=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=le.PUT,a.path="".concat(pe,"/").concat(encodeURIComponent(s),"/reset_user_history"),a}return s(n)}(Oe),Sp=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.ts_message_offset;return s.messageOffsetTimestamp=i,s}return s(n)}(Ue),Tp=Object.assign(Object.assign({},xl),{scheduledAt:void 0,file:void 0,fileUrl:void 0,fileName:void 0,mimeType:void 0,fileSize:void 0,thumbnailSizes:void 0,requireAuth:!1}),Ip=function(e){return Sl(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})))},Np=Object.assign(Object.assign({},Tl),{scheduledAt:void 0}),Mp=function(e){return Il(e)&&L("number",e.scheduledAt,!0)},Ap=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,l=t.scheduledMessageId;return s.method=le.PUT,s.path="".concat(Se(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),s.params=ue(ce({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 As.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:t.appleCriticalAlertOptions?xs.payloadify(t.appleCriticalAlertOptions):null,push_option:t.pushNotificationDeliveryOption})),s}return s(a)}(Oe),Op=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)}(Ue),Up=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,l=t.scheduledMessageId;return s.method=le.PUT,s.path="".concat(Se(u),"/").concat(encodeURIComponent(c),"/scheduled_messages/").concat(encodeURIComponent(l)),s.params=ue(ce({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:t.appleCriticalAlertOptions?xs.payloadify(t.appleCriticalAlertOptions):null,target_langs:t.translationTargetLanguages,push_option:t.pushNotificationDeliveryOption})),s}return s(a)}(Oe),Rp=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=le.DELETE,a.path="".concat(Se(s),"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(o)),a}return s(n)}(Oe),Lp=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=le.POST,a.path="".concat(Se(s),"/").concat(encodeURIComponent(i),"/scheduled_messages/").concat(encodeURIComponent(o),"/send_now"),a}return s(n)}(Oe),Dp=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=le.PUT,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push_preference/").concat(encodeURIComponent(i)),a.params={push_trigger_option:o},a}return s(n)}(Oe),Pp=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)}(Ue),Fp=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=le.GET,a.path="".concat(de,"/").concat(encodeURIComponent(s),"/push_preference/").concat(encodeURIComponent(i)),a}return s(n)}(Oe),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,a)).pushTriggerOption=a.push_trigger_option,s.enabled=a.enable,s}return s(n)}(Ue),qp=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=le.POST,a.path="".concat(Se(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/pin"),a}return s(n)}(Oe),Hp=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=le.DELETE,a.path="".concat(Se(s),"/").concat(encodeURIComponent(i),"/messages/").concat(o,"/pin"),a}return s(n)}(Oe),jp=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=Bs(e,a.message),s}return s(n)}(Ha),zp=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=le.GET,a.path="".concat(Se(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)}(Oe),Vp=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.pinned_messages,o=a.has_more,u=a.next;return s.pinnedMessages=i.map((function(t){return new jp(e,t)})),s.hasMore=o,s.token=u,s}return s(n)}(Ue),Bp=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 E(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=fs.of(this._iid),r=n.requestQueue,a=new zp(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Vp),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}(Li);e.CountPreference=void 0,(fp=e.CountPreference||(e.CountPreference={})).ALL="all",fp.UNREAD_MESSAGE_COUNT_ONLY="unread_message_count_only",fp.UNREAD_MENTION_COUNT_ONLY="unread_mention_count_only",fp.OFF="off",e.MutedState=void 0,(pp=e.MutedState||(e.MutedState={})).MUTED="muted",pp.UNMUTED="unmuted",e.HiddenState=void 0,(vp=e.HiddenState||(e.HiddenState={})).UNHIDDEN="unhidden",vp.HIDDEN_ALLOW_AUTO_UNHIDE="hidden_allow_auto_unhide",vp.HIDDEN_PREVENT_AUTO_UNHIDE="hidden_prevent_auto_unhide";var Qp,Kp=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,E,b,w,C,x,S;(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))&&(S=s.members).push.apply(S,_(n.members.map((function(e){return new dd(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?Bs(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 Xa(s._iid,n.inviter):null,s.invitedAt=null!==(E=n.invited_at)&&void 0!==E?E:0,s.joinedAt=null!==(b=n.joined_ts)&&void 0!==b?b:0,s._updateUnreadCount(null!==(w=n.unread_message_count)&&void 0!==w?w:0,null!==(C=n.unread_mention_count)&&void 0!==C?C:0),s.pinnedMessageIds=null!==(x=n.pinned_message_ids)&&void 0!==x?x:[],s.lastPinnedMessage=n.latest_pinned_message?Bs(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 Ms&&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=fs.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=fs.of(this._iid).sdkState,n=this._unreadMemberStateMap.get(t.userId);return!!n&&n>=e.createdAt}},{key:"serialize",value:function(){var e=this;return Wa(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 up(this._iid,Object.assign({channel:this},e))}},{key:"createMemberListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new _p(this._iid,this.url,e)}},{key:"createPinnedMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Bp(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 dd?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 Ms&&!this.isExclusive&&!this.isSuper&&!this.isBroadcast){var n,r=fs.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=fs.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof Ms?e.sender:null,s=[];return this.members.forEach((function(i){if(n||i.userId!==r.userId&&i.userId!==(null==a?void 0:a.userId)){var o=t._unreadMemberStateMap.get(i.userId);o&&o>=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=fs.of(this._iid).sdkState;if(!r.userId||this.isExclusive||this.isSuper||this.isBroadcast)return[];var a=e instanceof Ms?e.sender:null,s=[];return this.members.forEach((function(i){if(n||i.userId!==r.userId&&i.userId!==(null==a?void 0:a.userId)){var o=t._unreadMemberStateMap.get(i.userId);o&&o0&&void 0!==arguments[0]&&arguments[0],n=fs.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 fd(e._iid,{channel_url:e.url,channel_type:e.channelType,user:dd.payloadify(a),ts:null!=s?s:0})}})),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=fs.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 E(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=fs.of(this._iid),a=r.requestQueue,s=r.dispatcher,i=new Dd({channelUrl:this.url}),t.next=4,a.send(i);case 4:return o=t.sent,u=o.as(Pd),c=u.channel,this._update(c),s.dispatch(new du({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 E(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=fs.of(this._iid),a.dispatcher.dispatch(new du({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_FROZEN,isWebSocketEventComing:!0}));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 E(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=fs.of(this._iid),a.dispatcher.dispatch(new du({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNFROZEN,isWebSocketEventComing:!0}));case 4:case"end":return t.stop()}}),n,this)})))}},{key:"updateChannel",value:function(n){return E(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({},cp),n),Za(lp(a)).throw(A.invalidParameters),s=fs.of(this._iid),i=s.dispatcher,o=s.requestQueue,u=new yp(Object.assign({channelUrl:this.url},a)),t.next=6,o.send(u);case 6:return c=t.sent,l=c.as(kp),h=l.channel,this._update(h),i.dispatch(new du({channels:[h],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),t.abrupt("return",this);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"invite",value:function(e){return E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(e.every((function(e){return e instanceof Xa}))).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 E(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 Za(F("string",n)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.dispatcher,i=a.requestQueue,o=new uf({channelUrl:this.url,userIds:n}),t.next=5,i.send(o);case 5:return u=t.sent,c=u.as(cf),l=c.channel,this._update(l),s.dispatch(new du({channels:[l],source:e.GroupChannelEventSource.EVENT_CHANNEL_INVITED,isWebSocketEventComing:!0})),t.abrupt("return",this);case 10:case"end":return t.stop()}}),r,this)})))}},{key:"join",value:function(n){return E(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 Za(L("string",n,!0)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new nf({channelUrl:this.url,userId:i.userId,accessCode:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(rf),(h=l.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,this._update(h),s.dispatch(new du({channels:[h],source:e.GroupChannelEventSource.EVENT_CHANNEL_JOINED,isWebSocketEventComing:!0})),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 E(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=fs.of(this._iid),s=a.sdkState,i=a.requestQueue,o=new sf({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(n){return E(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 Za(L("string",n,!0)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new mp({channelUrl:this.url,userId:i.userId,accessCode:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(gp),(h=l.channel).myMemberState=this.myMemberState=e.MemberState.JOINED,this._update(h),s.dispatch(new du({channels:[h],source:e.GroupChannelEventSource.EVENT_CHANNEL_ACCEPTED_INVITE,isWebSocketEventComing:!0})),t.abrupt("return",this);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"declineInvitation",value:function(){return E(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=fs.of(this._iid),a=r.sdkState,s=r.requestQueue,i=new hf({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 Ci,a=fs.of(this._iid).dispatcher,s=iu.of(this._iid);return p(o(u.prototype),"sendUserMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(e)})).onFailed((function(e,t){t&&s.completeCurrentAndProcessNextAutoResend(t),r._triggerFailed(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),Ff.of(n._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),a.dispatch(new du({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(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 E(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=fs.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&&(Ff.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(h)})),o.dispatch(new du({channels:[this],source:l?e.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.GroupChannelEventSource.EVENT_MESSAGE_UPDATED}))),l&&Ff.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(h)})),o.dispatch(new ui({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 Ci,a=fs.of(this._iid).dispatcher,s=iu.of(this._iid);return p(o(u.prototype),"_autoResendUserMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(e)})).onFailed((function(e,t){s.completeCurrentAndProcessNextAutoResend(t),r._triggerFailed(e,t)})).onSucceeded((function(t){var i=Ff.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),i.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),a.dispatch(new du({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(t)})),r}},{key:"sendFileMessage",value:function(t){var n=this,r=new Ci,a=fs.of(this._iid).dispatcher,s=iu.of(this._iid);return p(o(u.prototype),"sendFileMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(e)})).onFailed((function(e,t){t&&s.completeCurrentAndProcessNextAutoResend(t),r._triggerFailed(e,t)})).onSucceeded((function(t){var i=Ff.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),i.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),a.dispatch(new du({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(t)})),r}},{key:"sendMultipleFilesMessage",value:function(t){var n=this,r=new Gi,a=fs.of(this._iid).dispatcher;return p(o(u.prototype),"sendMultipleFilesMessage",this).call(this,t).onPending((function(e){r._trigger(e)})).onFailed((function(e,t){r._triggerFailed(e,t)})).onSucceeded((function(t){var s=Ff.of(n._iid);n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),s.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),a.dispatch(new du({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(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 E(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=fs.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&&(Ff.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(h)})),o.dispatch(new du({channels:[this],source:l?e.GroupChannelEventSource.EVENT_PINNED_MESSAGE_UPDATED:e.GroupChannelEventSource.EVENT_MESSAGE_UPDATED}))),l&&Ff.of(this._iid).handlers.map((function(e){e.onPinnedMessageUpdated&&e.onPinnedMessageUpdated(h)})),o.dispatch(new ui({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 Ci,a=fs.of(this._iid).dispatcher,s=iu.of(this._iid);return p(o(u.prototype),"_autoResendFileMessage",this).call(this,t).onPending((function(e){s.completeCurrentAndProcessNextAutoResend(e),r._trigger(e)})).onFailed((function(e,t){s.completeCurrentAndProcessNextAutoResend(t),r._triggerFailed(e,t)})).onSucceeded((function(t){var i=Ff.of(n._iid);s.completeCurrentAndProcessNextAutoResend(t),n._shouldUpdateLastMessageWith(t)&&(n.lastMessage=t),i.handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(n)})),a.dispatch(new du({channels:[n],source:e.GroupChannelEventSource.EVENT_MESSAGE_SENT})),r._trigger(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 E(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 Ms&&(s=fs.of(this._iid),s.dispatcher.dispatch(new li({reqId:n.reqId,source:e.MessageEventSource.EVENT_MESSAGE_DELETED})));case 3:case"end":return t.stop()}}),r,this)})))}},{key:"hide",value:function(n){return E(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({},mf),n),Za(gf(a)).throw(A.invalidParameters),s=fs.of(this._iid),i=s.dispatcher,o=s.sdkState,u=s.requestQueue,c=new yf(Object.assign({channelUrl:this.url,userId:o.userId},a)),t.next=6,u.send(c);case 6:return l=t.sent,h=l.as(kf),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 du({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_HIDDEN,isWebSocketEventComing:!0})),t.abrupt("return",this);case 13:case"end":return t.stop()}}),r,this)})))}},{key:"unhide",value:function(){return E(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=fs.of(this._iid),a=r.dispatcher,s=r.requestQueue,i=new bp({channelUrl:this.url}),t.next=4,s.send(i);case 4:return this.hiddenState=e.HiddenState.UNHIDDEN,a.dispatch(new du({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UNHIDDEN,isWebSocketEventComing:!0})),t.abrupt("return",this);case 7:case"end":return t.stop()}}),n,this)})))}},{key:"delete",value:function(){return E(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=fs.of(this._iid),r=n.requestQueue,a=new Ep({channelUrl:this.url}),e.next=4,r.send(a);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"markAsRead",value:function(){return E(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=fs.of(this._iid),a=r.sdkState,s=r.dispatcher,i=r.requestQueue,o=new ff({channelUrl:this.url}),t.next=4,i.send(o);case 4:u=t.sent,c=u.as(pf),l=c.readStatus,this._updateUnreadMemberState(a.userId,l.readAt),(this.unreadMessageCount>0||this.unreadMentionCount>0)&&(this._updateUnreadCount(0,0),Ff.of(this._iid).handlers.map((function(e){e.onChannelChanged&&e.onChannelChanged(h)}))),s.dispatch(new du({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_READ}));case 9:case"end":return t.stop()}}),n,this)})))}},{key:"markAsDelivered",value:function(){return E(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=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new vf({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 E(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=fs.of(this._iid),r=n.requestQueue,a=n.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingStarted>=a&&(this._typingStarted=s,this._typingEnded=0,i=new bf({channelUrl:this.url,time:this._typingStarted}),r.send(i));case 3:case"end":return e.stop()}}),e,this)})))}},{key:"endTyping",value:function(){return E(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=fs.of(this._iid),r=n.requestQueue,a=n.typingIndicatorThrottle,(s=(new Date).getTime())-this._typingEnded>=a&&(this._typingStarted=0,this._typingEnded=s,i=new Cf({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({},Bo),e),Za(function(e){return Ao(e)&&L("number",e.scheduledAt,!0)}(e)).throw(A.invalidParameters);var t=new Ci;return this._createScheduledUserMessage(e,t),t}},{key:"updateScheduledUserMessage",value:function(e,n){return E(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({},Np),n),Za(Mp(a)).throw(A.invalidParameters),s=fs.of(this._iid),i=s.requestQueue,o=new Up(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(qh),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({},Qo),e),Za(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 Ci;return Ea(2).then((function(){var i=n._createPendingScheduledFileMessage(e,a,r);Ca((function(){return E(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(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 E(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({},Tp),n),Za(Ip(a)).throw(A.invalidParameters),!q(a.file)){t.next=5;break}return t.next=5,this._uploadFileAndUpdateParams(a);case 5:return s=new Ap(Object.assign({reqId:this._generateRequestId(),scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url},a)),i=fs.of(this._iid),o=i.requestQueue,t.next=9,o.send(s);case 9:return u=t.sent,c=u.as(Op),l=c.message,t.abrupt("return",l);case 12:case"end":return t.stop()}}),r,this)})))}},{key:"cancelScheduledMessage",value:function(e){return E(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 Rp({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),a=fs.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 E(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 Lp({scheduledMessageId:e,channelType:this.channelType,channelUrl:this.url}),a=fs.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 E(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=fs.of(this._iid),r=n.sdkState,a=n.requestQueue,s=new Fp({userId:r.userId,channelUrl:this.url}),e.next=4,a.send(s);case 4:return i=e.sent,o=i.as(Gp),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 E(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 Za(D(e.PushTriggerOption,n)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new Dp({userId:i.userId,channelUrl:this.url,pushTriggerOption:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(Pp),h=l.pushTriggerOption,this.myPushTriggerOption=h,s.dispatch(new du({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),t.abrupt("return",h);case 10:case"end":return t.stop()}}),r,this)})))}},{key:"setMyCountPreference",value:function(n){return E(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 Za(D(e.CountPreference,n)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.dispatcher,i=a.sdkState,o=a.requestQueue,u=new wp({channelUrl:this.url,userId:i.userId,countPreference:n}),t.next=5,o.send(u);case 5:return c=t.sent,l=c.as(Cp),h=l.countPreference,this.myCountPreference=h,this._updateUnreadCount(this.unreadMessageCount,this.unreadMentionCount),s.dispatch(new du({channels:[this],source:e.GroupChannelEventSource.EVENT_CHANNEL_UPDATED,isWebSocketEventComing:!0})),t.abrupt("return",h);case 11:case"end":return t.stop()}}),r,this)})))}},{key:"resetMyHistory",value:function(){return E(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=fs.of(this._iid),a=r.dispatcher,s=r.requestQueue,i=new xp({channelUrl:this.url}),t.next=4,s.send(i);case 4:return o=t.sent,u=o.as(Sp),c=u.messageOffsetTimestamp,this.messageOffsetTimestamp=c,this.lastMessage&&this.lastMessage.createdAt0).throw(A.invalidParameters),r=fs.of(this._iid),a=r.requestQueue,s=new qp({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 E(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 Za(L("number",e)&&e>0).throw(A.invalidParameters),r=fs.of(this._iid),a=r.requestQueue,s=new Hp({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 E(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=fs.of(this._iid),a=r.requestQueue,s=new vs({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(_s),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 ue(ce(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 dd.payloadify(e)})),last_message:e.lastMessage?Vs(e.lastMessage):null,inviter:e.inviter?Xa.payloadify(e.inviter):null,invited_at:e.invitedAt,joined_ts:e.joinedAt,pinned_message_ids:e.pinnedMessageIds,latest_pinned_message:e.lastPinnedMessage?Vs(e.lastPinnedMessage):null})))}}]),u}(nd),Wp={},Yp=function(){function n(a){var s=this,i=a._iid,o=a.limit,u=void 0===o?100:o;r(this,n),this.ref=0,this._iid=i,this._limit=u;var c,l=fs.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 Gf(p,(function(){return E(s,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 o={hasNext:!0,nextToken:""},t.next=3,this.loadMetadata();case 3:if(f.debug("channel background sync from",null===(r=this._metadata)||void 0===r?void 0:r.token),null===(a=this._metadata)||void 0===a?void 0:a.completed){t.next=29;break}return t.prev=5,u=Ff.of(this._iid),t.next=9,u.getMyGroupChannels(null!==(i=null===(s=this._metadata)||void 0===s?void 0:s.token)&&void 0!==i?i:"",{includeEmpty:!0,order:e.GroupChannelListOrder.CHRONOLOGICAL},this._limit,e.GroupChannelEventSource.SYNC_CHANNEL_BACKGROUND);case 9:return c=t.sent,l=c.channels,h=c.token,o.hasNext=l.length>=this._limit&&!!h,o.nextToken=h,this._metadata&&(this._metadata.token=h,(d=this._metadata.range).extends.apply(d,_(l.map((function(e){return e.createdAt})))),this._metadata.completed=!o.hasNext),f.debug("channel background sync progress",o),t.next=18,this.saveMetadata();case 18:t.next=27;break;case 20:if(t.prev=20,t.t0=t.catch(5),f.debug("channel background sync error",t.t0),!(t.t0 instanceof A&&t.t0.isInvalidTokenError)){t.next=26;break}return t.next=26,this.clearMetaData();case 26:throw t.t0;case 27:t.next=31;break;case 29:o.hasNext=!1,o.nextToken="";case 31:return t.abrupt("return",o);case 32:case"end":return t.stop()}}),n,this,[[5,20]])})))})),this._connectionEventContext=d.on((function(e){if(e instanceof da)if(e.stateType===sa.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"range",get:function(){var e,t;return null!==(t=null===(e=this._metadata)||void 0===e?void 0:e.range)&&void 0!==t?t:new Lf({})}},{key:"completed",get:function(){var e;return!!(null===(e=this._metadata)||void 0===e?void 0:e.completed)}},{key:"loadMetadata",value:function(){return E(this,void 0,void 0,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=fs.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 Lf(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 E(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=fs.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 E(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=fs.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){var e,t,n=fs.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(){fs.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 Wp[this._iid])}}],[{key:"of",value:function(e){return Wp[e]||(Wp[e]=new n({_iid:e})),Wp[e].ref++,Wp[e]}},{key:"clear",value:function(e){Wp[e]&&(Wp[e].close(),delete Wp[e])}}]),n}(),Zp={},Jp=function(){function n(a){var s=this,i=a._iid;r(this,n),this.ref=0,this._iid=i;var o,u=fs.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 Gf(d,(function(){return E(s,void 0,void 0,t().mark((function n(){var r,a,s,i,o,u,l,h;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i={hasNext:!0,nextToken:0},t.next=3,this.loadMetadata();case 3:return c.debug("channel changelog sync from",null===(r=this._metadata)||void 0===r?void 0:r.token),t.prev=4,o=Ff.of(this._iid),t.next=8,o.getMyGroupChannelChangeLogs(null!==(s=null===(a=this._metadata)||void 0===a?void 0:a.token)&&void 0!==s?s:"",{includeEmpty:!0},e.GroupChannelEventSource.SYNC_CHANNEL_CHANGELOGS);case 8:return u=t.sent,l=u.hasMore,h=u.token,i.hasNext=l,i.nextToken=h,this._metadata&&(this._metadata.token=h),c.debug("channel changelog sync progress",i),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",i);case 27:case"end":return t.stop()}}),n,this,[[4,19]])})))})),this._connectionEventContext=h.on((function(e){if(e instanceof da)if(e.stateType===sa.CONNECTED)s.resume();else s.pause()}))}return s(n,[{key:"loadMetadata",value:function(){return E(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=fs.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 E(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=fs.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 E(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=fs.of(this._iid),r=n.cacheContext,e.next=3,r.preference.remove(this._metadataKey);case 3:this._metadata=void 0;case 4:case"end":return e.stop()}}),e,this)})))}},{key:"resume",value:function(){fs.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 Zp[this._iid])}}],[{key:"of",value:function(e){return Zp[e]||(Zp[e]=new n({_iid:e})),Zp[e].ref++,Zp[e]}},{key:"clear",value:function(e){Zp[e]&&(Zp[e].close(),delete Zp[e])}}]),n}(),Xp=function(){function n(a,s){var i=this,o=s.filter,u=s.order,c=s.limit;r(this,n),this.channels=[],this._iid=a,this._key="gcc-".concat(re()),this._isDisposed=!1,this._isGetRemoteChannelsSucceeded=!0,this.filter=null!=o?o:new vd,this.order=null!=u?u:e.GroupChannelListOrder.LATEST_LAST_MESSAGE,this._hasMore=!0,this._token="",this._limit=null!=c?c:100;var l=fs.of(this._iid),h=l.sdkState,d=l.cacheContext,f=l.dispatcher;d.localCacheEnabled&&(this._backgroundSync=Yp.of(a),this._backgroundSync.resume()),this._changelogSync=Jp.of(a),this._changelogSync.resume(),Ff.of(this._iid).subscribeGroupChannelEvent(this._key,{onUpdate:function(e,t){if(hu(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)}}),fs.of(this._iid).statLogCollector.put(new ss({type:Ae.FEATURE_LOCALCACHE,data:{use_local_cache:d.localCacheEnabled,collection_interface:{group_channel:!0}}})),f.on((function(e){e instanceof da&&(e.stateType===sa.CONNECTED?i._isGetRemoteChannelsSucceeded||E(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===sa.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=Jf(this.channels,h);d>=0&&this.channels.splice(d,1);var f=Xf(this.channels,h,this.order).place;if(d<0)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!==d&&this._hasMore&&f===this.channels.length?c.push(h):(this.channels.splice(f,0,h),u.push(h));break;default:this.channels.splice(f,0,h),u.push(h)}}}catch(e){l.e(e)}finally{l.f()}if(c.length>0){var p,v=y(c);try{for(v.s();!(p=v.n()).done;){var _=p.value,m=Jf(this.channels,_);-1!==m&&this.channels.splice(m,1)}}catch(e){v.e(e)}finally{v.f()}}hu(r)&&Ca((function(){return E(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 qf(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 hu(n)&&s.length>0&&Ca((function(){return E(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 qf(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 E(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=Ff.of(this._iid),r=this.channels.length>0?Zf(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:void 0);case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)})))}},{key:"_getRemoteChannels",value:function(){return E(this,void 0,void 0,t().mark((function e(){var n,r,a,s;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Ff.of(this._iid),e.next=3,n.getMyGroupChannels(this._token,ce(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 E(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 E(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:b.COLLECTION_DISPOSED,message:"Collection has been disposed."});case 2:if(!this._hasMore){n.next=23;break}if(r=fs.of(this._iid),a=r.cacheContext,s=[],!a.localCacheEnabled||!this._backgroundSync.completed){n.next=11;break}return n.next=8,xa((function(){return E(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(),Ff.of(this._iid).unsubscribeGroupChannelEvent(this._key))}}]),n}(),$p=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,E=t.includeMetaData;return(s=n.call(this)).method=le.GET,s.path=pe,s.params=ue(ce({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:E})),s}return s(a)}(Oe),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)).channels=[];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 Kp(e,t)}))),s.ts="number"==typeof u?u:0,s}return s(n)}(Ue);e.MembershipFilter=void 0,(Qp=e.MembershipFilter||(e.MembershipFilter={})).ALL="all",Qp.JOINED="joined";var tv,nv=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 E(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=fs.of(this._iid),a=r.requestQueue,r.dispatcher,s=new $p(ce(Object.assign(Object.assign({},this),{token:this._token}))),e.next=9,a.send(s);case 9:return i=e.sent,o=i.as(ev),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}(Ii),rv=s((function e(){r(this,e),this.onUserMuted=He,this.onUserUnmuted=He,this.onUserBanned=He,this.onUserUnbanned=He,this.onChannelChanged=He,this.onChannelDeleted=He,this.onChannelFrozen=He,this.onChannelUnfrozen=He,this.onOperatorUpdated=He,this.onChannelMemberCountChanged=He,this.onMetaDataCreated=He,this.onMetaDataUpdated=He,this.onMetaDataDeleted=He,this.onMetaCounterCreated=He,this.onMetaCounterUpdated=He,this.onMetaCounterDeleted=He,this.onMessageReceived=He,this.onMessageUpdated=He,this.onMessageDeleted=He,this.onMentionReceived=He,this.onReactionUpdated=He,this.onThreadInfoUpdated=He})),av=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.apply(this,arguments)).onUserJoined=He,e.onUserLeft=He,e.onUserReceivedInvitation=He,e.onUserDeclinedInvitation=He,e.onChannelHidden=He,e.onUnreadMemberStatusUpdated=He,e.onUndeliveredMemberStatusUpdated=He,e.onTypingStatusUpdated=He,e.onPollUpdated=He,e.onPollVoted=He,e.onPollDeleted=He,e.onPinnedMessageUpdated=He,e}return s(n)}(rv),sv=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)}(av),iv=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=le.GET,a.path="".concat(we),a.params=ue(ce({token:s,limit:i,reverse:u,channel_url:c,order:o,message_type:l,status:h})),a}return s(n)}(Oe),ov=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).scheduledMessages=[];var i=a.next,o=a.scheduled_messages;return s.token=i,s.scheduledMessages=o.map((function(t){return Bs(e,t)})),s}return s(n)}(Ue),uv=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 E(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=fs.of(this._iid),r=n.requestQueue,a=new iv(ce(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(ov),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}(Ii),cv=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 Ff(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 Xp(this._iid,e)}},{key:"createMyGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Rf(this._iid,e)}},{key:"createPublicGroupChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new nv(this._iid,e)}},{key:"createScheduledMessageListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new uv(this._iid,e)}},{key:"addGroupChannelHandler",value:function(e,t){Za(L("string",e)&&t instanceof sv).throw(A.invalidParameters),this._manager.addHandler(e,t)}},{key:"removeGroupChannelHandler",value:function(e){Za(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 E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(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 E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Za(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 E(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({},Ed),n),Za(L("string",e)&&bd(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 E(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({},Ed),n),Za(L("number",e)&&bd(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 E(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({},wd),e),Za(Cd(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 E(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 E(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 E(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 E(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 E(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({},yd),e),Za(kd(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 E(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({},yd),e),Za(kd(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?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";return E(this,void 0,void 0,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({},yd),{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 E(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 E(this,void 0,void 0,t().mark((function n(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:Za(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 E(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 Za(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}(ps),lv=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!!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){return E(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._channels.get(e));case 1:case"end":return t.stop()}}),n,this)})))}},{key:"upsert",value:function(e){return E(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 E(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 E(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}(Ha),hv={channelUrl:void 0,name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0,isEphemeral:void 0},dv=function(e){return F("string",e.operatorUserIds,!0)&&(L("string",e.coverUrlOrImage,!0)||q(e.coverUrlOrImage,!0))&&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||void 0===e.channelUrl)&&L("boolean",e.isEphemeral,!0)},fv=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=le.GET,a.path="".concat(i?me:_e,"/").concat(encodeURIComponent(s)),a}return s(n)}(Oe),pv=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 Mv(e,a),s}return s(n)}(Ue),vv=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=le.POST,a.path=_e,a.params=ue(ce({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)}(Oe),_v=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)}(oa),mv=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 Xa(e,s.data),i.ts=null!==(u=s.data.edge_ts)&&void 0!==u?u:0),i}return s(n)}(tf),gv=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)}(oa),yv=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 Xa(e,s.data),i.ts=null!==(u=s.data.edge_ts)&&void 0!==u?u:0),i}return s(n)}(tf),kv={},Ev=function(){function n(e,t){var a=this,s=t.sdkState,i=t.dispatcher,o=t.requestQueue;return r(this,n),kv[e]||(this._iid=e,this._sdkState=s,this._requestQueue=o,this._dispatcher=i,this._openChannelCache=new lv(e),this._openChannelHandlers=new Map,this._dispatcher.on((function(e){if(e instanceof qe)a._handleEvent(e);else if(e instanceof da&&e.stateType===sa.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()}}})),kv[e]=this),kv[e]}return s(n,[{key:"buildOpenChannelFromSerializedData",value:function(e){var t=Ya(e);return new Mv(this._iid,Mv.payloadify(t))}},{key:"getChannelFromCache",value:function(e){var n;return E(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._openChannelCache.get(e);case 2:if(t.t1=n=t.sent,t.t0=null!==t.t1,!t.t0){t.next=6;break}t.t0=void 0!==n;case 6:if(!t.t0){t.next=10;break}t.t2=n,t.next=11;break;case 10:t.t2=null;case 11:return t.abrupt("return",t.t2);case 12:case"end":return t.stop()}}),r,this)})))}},{key:"upsertChannelsToCache",value:function(e){return E(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 E(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 E(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,b,w,C,x,S,T,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,Ee,be,we,Ce,xe,Se,Te,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(Sh):"FILE"===n.code?a=n.as(Ys):"ADMM"!==n.code&&"BRDM"!=n.code||(a=n.as(Nf)),!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,Ca((function(){return E(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&&a.onMessageReceived(u,i),o&&a.onMentionReceived&&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(Ih):"FEDI"===n.code?c=n.as(Mh):"AEDI"===n.code&&(c=n.as(Mf)),!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,Ca((function(){return E(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&&a.onMessageUpdated(f,h),d>0&&a.onMentionReceived&&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(Oh),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,Ca((function(){return E(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&&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(Af),b=k.channelUrl,w=k.channelType,C=k.event,w!==e.ChannelType.OPEN){r.next=37;break}return r.next=35,this.getChannel(b,!0);case 35:x=r.sent,Ca((function(){return E(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(x.url)&&a.onReactionUpdated&&a.onReactionUpdated(x,C)}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(S=n.as(Of),(T=S.event).channelType!==e.ChannelType.OPEN){r.next=44;break}return r.next=42,this.getChannel(T.channelUrl,!0);case 42:I=r.sent,Ca((function(){return E(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&&a.onThreadInfoUpdated(I,T)}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(Tf),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,Ca((function(){return E(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).onChannelMemberCountChanged&&a.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(Uf),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 di({event:j,source:e.MessageEventSource.EVENT_POLL_UPDATED})),Ca(z===Ds?function(){return E(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).onPollDeleted&&a.onPollDeleted(Q,j.pollId)}catch(e){n.e(e)}finally{n.f()}case 2:case"end":return e.stop()}}),e,this)})))}:function(){return E(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).onPollUpdated&&a.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(td),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 fi({event:W,source:e.MessageEventSource.EVENT_POLL_VOTED})),Ca((function(){return E(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).onPollVoted&&a.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(tf),!($=X.event).isOpenChannelEvent){r.next=165;break}r.t2=$.category,r.next=r.t2===pd.CHANNEL_ENTER?94:r.t2===pd.CHANNEL_EXIT?101:r.t2===pd.CHANNEL_OPERATOR_UPDATE?108:r.t2===pd.USER_CHANNEL_MUTE||r.t2===pd.USER_CHANNEL_UNMUTE?116:r.t2===pd.USER_CHANNEL_BAN||r.t2===pd.USER_CHANNEL_UNBAN?123:r.t2===pd.CHANNEL_FREEZE||r.t2===pd.CHANNEL_UNFREEZE?130:r.t2===pd.CHANNEL_DELETED?138:r.t2===pd.CHANNEL_PROP_CHANGED?145:r.t2===pd.CHANNEL_META_DATA_CHANGED?150:r.t2===pd.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(mv),ne=te.participantCount,re=te.user,ae=ee._updateParticipantCount(ne,$.ts),Ca((function(){return E(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&&e.onUserEntered(ee,re),ae&&e.onChannelParticipantCountChanged&&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(yv),oe=ie.participantCount,ue=ie.user,ce=se._updateParticipantCount(oe,$.ts),Ca((function(){return E(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&&e.onUserExited(se,ue),ce&&e.onChannelParticipantCountChanged&&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(Sf),de=he.operators,le.operators=de,this.upsertChannelsToCache([le]),Ca((function(){return E(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&&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===pd.USER_CHANNEL_MUTE,ve=n.as(pe?fh:vh),_e=ve.user,Ca((function(){return E(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&&e.onUserMuted(fe,_e):e.onUserUnmuted&&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===pd.USER_CHANNEL_BAN,ye=n.as(ge?mh:yh),ke=ye.user,Ca((function(){return E(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&&e.onUserBanned(me,ke):e.onUserUnbanned&&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 Ee=r.sent,be=n.as(Eh),we=be.freeze,Ee.isFrozen=we,this.upsertChannelsToCache([Ee]),Ca((function(){return E(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&&e.onChannelFrozen(Ee):e.onChannelUnfrozen&&e.onChannelUnfrozen(Ee)}));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 Ce=r.sent,r.next=143,this.removeChannelsFromCache([Ce.url]);case 143:return Ca((function(){return E(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&&e.onChannelDeleted(Ce.url,Ce.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 xe=r.sent,Ca((function(){return E(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&&e.onChannelChanged(xe)}));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 Se=r.sent,Te=n.as(Xl),Ie=Te.created,Ne=Te.updated,Me=Te.deleted,Ie&&Se._upsertCachedMetaData(Ie,$.ts),Ne&&Se._upsertCachedMetaData(Ne,$.ts),Me&&Se._removeFromCachedMetaData(Me,$.ts),Ca((function(){return E(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&&e.onMetaDataCreated(Se,Ie),Ne&&e.onMetaDataUpdated&&e.onMetaDataUpdated(Se,Ne),Me&&e.onMetaDataDeleted&&e.onMetaDataDeleted(Se,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(ch),Ue=Oe.created,Re=Oe.updated,Le=Oe.deleted,Ca((function(){return E(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&&e.onMetaCounterCreated(Ae,Ue),Re&&e.onMetaCounterUpdated&&e.onMetaCounterUpdated(Ae,Re),Le&&e.onMetaCounterDeleted&&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 E(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 Za(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 E(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 Za(L("string",e)).throw(A.invalidParameters),a=new fv({channelUrl:e,isInternalCall:n}),t.next=4,this._requestQueue.send(a);case 4:return s=t.sent,i=s.as(pv),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 E(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({},hv),e),Za(dv(r)).throw(A.invalidParameters),a=new vv(r),t.next=5,this._requestQueue.send(a);case 5:return s=t.sent,i=s.as(pv),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 kv[e]}}]),n}(),bv={name:void 0,coverUrlOrImage:void 0,data:void 0,customType:void 0,operatorUserIds:void 0},wv=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)},Cv=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=le.GET,a.path="".concat(_e,"/").concat(encodeURIComponent(s),"/participants"),a.params={token:i,limit:o},a}return s(n)}(Oe),xv=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).participants=[];var i=a.next,o=a.participants;return s.token=i,s.participants=o.map((function(t){return new Cl(e,t)})),s}return s(n)}(Ue),Sv=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 E(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=fs.of(this._iid),r=n.requestQueue,a=new Cv(Object.assign(Object.assign({},this),{token:this._token})),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(xv),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}(Li),Tv=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=le.PUT,a.path="".concat(_e,"/").concat(encodeURIComponent(s)),a.params=ue(ce({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)}(Oe),Iv=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 Mv(e,a),s}return s(n)}(Ue),Nv=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=le.DELETE,a.path="".concat(_e,"/").concat(encodeURIComponent(s)),a}return s(n)}(Oe),Mv=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 Xa(t,e)})):[],s}return s(u,[{key:"serialize",value:function(){return Wa(this)}},{key:"isOperator",value:function(e){return e instanceof Xa?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 Sv(this._iid,this.url,e)}},{key:"refresh",value:function(){return E(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=Ev.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 E(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=fs.of(this._iid),r=n.requestQueue,a=new _v({channelUrl:this.url}),e.next=4,r.send(a);case 4:s=e.sent,i=s.as(mv),o=i.participantCount,u=i.ts,this._updateParticipantCount(o,u),Ev.of(this._iid).setEnteredToCache(this);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"exit",value:function(){return E(this,void 0,void 0,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=fs.of(this._iid),r=n.requestQueue,a=new gv({channelUrl:this.url}),e.next=4,r.send(a);case 4:s=e.sent,i=s.as(yv),o=i.participantCount,u=i.ts,this._updateParticipantCount(o,u),Ev.of(this._iid).setExitedToCache(this),wi.of(this._iid).fileMessageQueue.cancel(this);case 11:case"end":return e.stop()}}),e,this)})))}},{key:"updateChannel",value:function(e){return E(this,void 0,void 0,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({},bv),e),Za(wv(r)).throw(A.invalidParameters),a=fs.of(this._iid),s=a.requestQueue,i=new Tv(Object.assign({channelUrl:this.url},r)),t.next=6,s.send(i);case 6:return o=t.sent,u=o.as(Iv),c=u.channel,this._update(c),l=Ev.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 E(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({},bv),{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 E(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=fs.of(this._iid),r=n.requestQueue,a=new Nv({channelUrl:this.url}),e.next=4,r.send(a);case 4:return s=Ev.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 Za(!e.isPinnedMessage).throw(A.notSupportedError),p(o(u.prototype),"sendUserMessage",this).call(this,e)}},{key:"sendFileMessage",value:function(e){return Za(!e.isPinnedMessage).throw(A.notSupportedError),p(o(u.prototype),"sendFileMessage",this).call(this,e)}}],[{key:"payloadify",value:function(e){return ue(ce(Object.assign(Object.assign({},nd.payloadify(e)),{participant_count:e.participantCount,operators:e.operators.map((function(e){return Xa.payloadify(e)}))})))}}]),u}(nd),Av=function(e){i(n,e);var t=f(n);function n(){var e;return r(this,n),(e=t.apply(this,arguments)).onUserEntered=He,e.onUserExited=He,e.onChannelParticipantCountChanged=He,e.onPollUpdated=He,e.onPollVoted=He,e.onPollDeleted=He,e}return s(n)}(rv),Ov=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)}(Av),Uv=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=le.GET,a.path=_e,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)}(Oe),Rv=function(e){i(n,e);var t=f(n);function n(e,a){var s;r(this,n),(s=t.call(this,e,a)).channels=[];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 Mv(e,t)}))),s.ts="number"==typeof u?u:null,s}return s(n)}(Ue),Lv=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 E(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=fs.of(this._iid),r=n.requestQueue,a=new Uv(ce(Object.assign(Object.assign({},this),{token:this._token}))),e.next=8,r.send(a);case 8:return s=e.sent,i=s.as(Rv),o=i.channels,u=i.token,this._token=u,this._hasNext=!!u,c=Ev.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}(Ii),Dv=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 Ev(e,{sdkState:n,dispatcher:r,requestQueue:i})}},{key:"createOpenChannelListQuery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Lv(this._iid,e)}},{key:"addOpenChannelHandler",value:function(e,t){this._manager.addHandler(e,t)}},{key:"removeOpenChannelHandler",value:function(e){this._manager.removeHandler(e)}},{key:"removeAllOpenChannelHandlers",value:function(){this._manager.clearHandler()}},{key:"buildOpenChannelFromSerializedData",value:function(e){return this._manager.buildOpenChannelFromSerializedData(e)}},{key:"getChannel",value:function(e){return E(this,void 0,void 0,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 E(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 E(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 E(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({},hv)).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}(ps);tv=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 Qv(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 Kv(e){return"string"!=typeof e&&(e=String(e)),e}function Wv(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return qv&&(t[Symbol.iterator]=function(){return t}),t}function Yv(e){this.map={},e instanceof Yv?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){if(2!=e.length)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+e.length);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._noBody)return e.bodyUsed?Promise.reject(new TypeError("Already read")):void(e.bodyUsed=!0)}function Jv(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function Xv(e){var t=new FileReader,n=Jv(t);return t.readAsArrayBuffer(e),n}function $v(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function e_(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:Hv&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:jv&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:Gv&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():zv&&Hv&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=$v(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):zv&&(ArrayBuffer.prototype.isPrototypeOf(e)||Bv(e))?this._bodyArrayBuffer=$v(e):this._bodyText=e=Object.prototype.toString.call(e):(this._noBody=!0,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):Gv&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},Hv&&(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))}if(Hv)return this.blob().then(Xv);throw new Error("could not read as ArrayBuffer")},this.text=function(){var e=Zv(this);if(e)return e;if(this._bodyBlob)return function(e){var t=new FileReader,n=Jv(t),r=/charset=([A-Za-z0-9_-]+)/.exec(e.type),a=r?r[1]:"utf-8";return t.readAsText(e,a),n}(this._bodyBlob);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||function(){if("AbortController"in Fv)return(new AbortController).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 r_(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 a_(e,t){if(!(this instanceof a_))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new Yv(t.headers),this.url=t.url||"",this._initBody(e)}n_.prototype.clone=function(){return new n_(this,{body:this._bodyInit})},e_.call(n_.prototype),e_.call(a_.prototype),a_.prototype.clone=function(){return new a_(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new Yv(this.headers),url:this.url})},a_.error=function(){var e=new a_(null,{status:200,statusText:""});return e.status=0,e.type="error",e};var s_=[301,302,303,307,308];a_.redirect=function(e,t){if(-1===s_.indexOf(t))throw new RangeError("Invalid status code");return new a_(null,{status:t,headers:{location:e}})};var i_=Fv.DOMException;try{new i_}catch(sn){(i_=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack}).prototype=Object.create(Error.prototype),i_.prototype.constructor=i_}function o_(e,t){return new Promise((function(r,a){var s=new n_(e,t);if(s.signal&&s.signal.aborted)return a(new i_("Aborted","AbortError"));var i=new XMLHttpRequest;function o(){i.abort()}if(i.onload=function(){var e=i.getAllResponseHeaders(),t=i.getResponseHeader("set-cookie");t&&(e=e.replace(t,t.replace(/\r?\n/g,", ")));var n,a,s={status:i.status,statusText:i.statusText,headers:(n=e||"",a=new Yv,n.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 t=e.split(":"),n=t.shift().trim();if(n){var r=t.join(":").trim();try{a.append(n,r)}catch(e){console.warn("Response "+e.message)}}})),a)};s.url="responseURL"in i?i.responseURL:s.headers.get("X-Request-URL");var o="response"in i?i.response:i.responseText;setTimeout((function(){r(new a_(o,s))}),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 i_("Aborted","AbortError"))}),0)},i.open(s.method,function(e){try{return""===e&&Fv.location.href?Fv.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&&(Hv?i.responseType="blob":zv&&(i.responseType="arraybuffer")),t&&"object"===n(t.headers)&&!(t.headers instanceof Yv||Fv.Headers&&t.headers instanceof Fv.Headers)){var u=[];Object.getOwnPropertyNames(t.headers).forEach((function(e){u.push(Qv(e)),i.setRequestHeader(e,Kv(t.headers[e]))})),s.headers.forEach((function(e,t){-1===u.indexOf(t)&&i.setRequestHeader(t,e)}))}else s.headers.forEach((function(e,t){i.setRequestHeader(t,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)}))}o_.polyfill=!0,Fv.fetch||(Fv.fetch=o_,Fv.Headers=Yv,Fv.Request=n_,Fv.Response=a_);var u_=Object.freeze({__proto__:null});return e.AdminMessage=Rs,e.AppleCriticalAlertOptions=xs,e.ApplicationUserListQuery=gc,e.BannedUserListQuery=Gl,e.BaseChannel=nd,e.BaseMessage=Ns,e.BlockedUserListQuery=Ec,e.CachedChannelInfo=ee,e.ConnectionHandler=_o,e.Emoji=sc,e.EmojiCategory=ic,e.EmojiContainer=oc,e.FileMessage=Qs,e.FriendListQuery=Cc,e.GroupChannel=Kp,e.GroupChannelCollection=Xp,e.GroupChannelEventContext=qf,e.GroupChannelFilter=vd,e.GroupChannelHandler=sv,e.GroupChannelListQuery=Rf,e.GroupChannelModule=cv,e.LocalCacheConfig=te,e.Member=dd,e.MemberListQuery=_p,e.MemoryStore=ll,e.MessageCollection=up,e.MessageCollectionInitHandler=op,e.MessageEventContext=Hf,e.MessageFilter=wo,e.MessageMetaArray=bs,e.MessageModule=qi,e.MessageRequestHandler=Ci,e.MessageSearchQuery=Ri,e.MultipleFilesMessage=zs,e.MultipleFilesMessageRequestHandler=Gi,e.MutedUserListQuery=Dl,e.OGImage=ws,e.OGMetaData=Cs,e.OpenChannel=Mv,e.OpenChannelHandler=Ov,e.OpenChannelListQuery=Lv,e.OpenChannelModule=Dv,e.OperatorListQuery=Ul,e.Participant=Cl,e.ParticipantListQuery=Sv,e.PinnedMessage=jp,e.PinnedMessageListQuery=Bp,e.Plugin=Ls,e.PreviousMessageListQuery=Di,e.PublicGroupChannelListQuery=nv,e.Reaction=Es,e.ReactionEvent=ks,e.ReadStatus=fd,e.RestrictedUser=wl,e.RestrictionInfo=bl,e.ScheduledMessageListQuery=uv,e.SendbirdChat=rd,e.SendbirdChatOptions=H,e.SendbirdError=A,e.Sender=Ss,e.SessionHandler=vo,e.ThreadInfo=ms,e.ThreadInfoUpdateEvent=xi,e.Thumbnail=As,e.UIKitConfigInfo=Fa,e.UploadedFileInfo=js,e.User=Xa,e.UserEventHandler=mo,e.UserMessage=Hs,Object.defineProperty(e,"__esModule",{value:!0}),e}({});